Home > Back-end >  Visual studio set up and the database connection error
Visual studio set up and the database connection error

Time:06-11


You this how to solve my great god in visual studio set up the contact database error for it; Not all code paths return value that how to get here is all the code
using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. The Data. SqlClient.
Using System. Drawing;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. Windows. Forms;

The namespace StudentInfo
{
Public partial class frmLogin: Form
{
Public frmLogin ()
{
InitializeComponent();
}

Private void btnLogin_Click (object sender, EventArgs e)
{
If ((())
{
FrmMain mainform=new frmMain ();
Mainform. The Show ();
Enclosing the Visible=false;
}
}
Private bool (()
{
If ((())
{
String paramAdminName=this. TxtLoginName. Text. The Trim ();
String paramAdminPwd=this. TxtLoginPwd. Text. The Trim ();
Int count=0;
//string connString="server=. The database=StudentManagement; Uid=sa; The PWD=123; ";
String connString="Data Source=(local); Initial Catalog=StudentManagement; Integrated Security=SSPI; ";
//set up and open the database connection
SqlConnection connection=new SqlConnection (connString);
String this="SELECT COUNT (*) FROM AdminInfo WHERE adminName='" + paramAdminName +"' AND adminPwd='" + paramAdminPwd + "";
//create the Command Command
SqlCommand command=new SqlCommand ();
//create the DataReader object
Command. The Connection=Connection;
Command.Com mandText=this;
Connection. The Open ();
Count=(int) command. ExecuteScalar ();
Connection. The Close ();
If (count>
=1){
FrmMain myUIMain=new frmMain ();
MyUIMain. The Show ();
This. Hide ();
}
The else
{
MessageBox. Show (" username or password does not exist!" );
This. TxtLoginName. Text=string. The Empty;
This. TxtLoginPwd. Text=string. The Empty;
}
}
}

Private void btnCancel_Click (object sender, EventArgs e)
{
Application. The Exit ();
}
}
}

CodePudding user response:

Send the wrong plates, this seems to be c #?

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related