日期:2014-05-17 浏览次数:20868 次
public void connect(string queryStr,string connString)
{
/* SqlConnection sqlConn = new SqlConnection();
sqlConn.ConnectionString = "Server=localhost;Catalog=ConsoleYang;uid=administrator;password=";
sqlConn.Open();
*/
//下面这一行抛异常
using (SqlConnection conn = new SqlConnection(connString))
{
SqlCommand command = new SqlCommand(queryStr,conn);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
public void RegisterTwo()
{
string username = Console.ReadLine();
string password = Console.ReadLine();
NormalUser normalUser = new NormalUser();
normalUser.Password = password;
normalUser.Username = username;
ConnDataBase database = new ConnDataBase();
string queryString = "select * from table";
string connString = "Server=localhost;Catelog=ConsoleYang;uid=sa;password=";
database.connect(queryString,connString);
}