慕尼黑的夜晚无繁华
一个简单的例子: private DataTable sget(){SqlConnection conn = new SqlConnection(@"Data Source=.\sqlexpress;database=Asp600;user id=sa;password=123");//()里面是连接数据库的字符串,连接后用sqlconnection对象SqlDataAdapter ad=new SqlDataAdapter("select top 10 * from Count_Iplocal", conn);DataTable ds = new DataTable();ad.Fill(ds);return ds; }