c#代码中连接sql server的写法:
复制代码 代码示例:
string strconn = "data source = (local);initial catalog = sxaic; user id = sa;password = 123456";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = strconn;
conn.Open();
string sql = "select * from t_brand";
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sql,conn);
DataSet ds = new DataSet();
sqlAdapter.Fill(ds,"t_brand");
Label1.Text = ds.Tables[0].Rows[0]["brand"].ToString();
conn.Close();