數據庫讀寫操作


string connStr = string.Format("server={0};User ID={1};Password={2};database={3};Connection Reset=FALSE;Asynchronous Processing=true",".\\SQLEXPRESS", "sa","123456" ,"學生信息");
SqlConnection cn = new SqlConnection(connStr);

cn.Open();

string str = "select * from stu_1";
SqlCommand cmd = new SqlCommand(str, cn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",
reader[0], reader[1]));
}

}

public static string localhost { get; set; }

public static object 學生信息 { get; set; }


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com