日期:2014-05-17 浏览次数:20876 次
try
{
string strCon = "Data Source=192.168.1.2;Initial Catalog=Temp;User ID=sa;Pwd=sa";
SqlConnection myConn = new SqlConnection(strCon);
string strCom = "SELECT * FROM table";
SqlCommand myCmd = myConn.CreateCommand();
myCmd.CommandText = strCom;
myConn.Open();
SqlDataReader myreader = myCmd.ExecuteReader();
while (myreader.Read())
{
string st1 = (string)myreader[0].ToString(); // 字段1
string st2 = (string)myreader[1].ToString(); // 字段2 &n