当前位置:Gxlcms > 数据库问题 > 【C#学习笔记】读SQL Server2008

【C#学习笔记】读SQL Server2008

时间:2021-07-01 10:21:17 帮助过:12人阅读

System; using System.Data.SqlClient; namespace ConsoleApplication { class Program { static void Main(string[] args) { SqlConnection con = new SqlConnection("server=.\\sqlexpress;uid=sa;pwd=123456;database=stuDB"); con.Open(); SqlCommand com = con.CreateCommand(); com.CommandText = "select * from stuInfo"; SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) Console.WriteLine(reader["stuName"].ToString() + reader["stuAge"].ToString() + reader["stuSex"].ToString()); reader.Close(); con.Close(); Console.Read(); } } }

 

【C#学习笔记】读SQL Server2008

标签:main   UI   code   tostring   oid   class   create   ring   ext   

人气教程排行