Greetings,
I am attempting to read data from a SQL Server 2005 table. I have the following code below but I'm obviously missing something. When I put a watch on the variable, "strData", the value is the following:
"System.Data.SqlClient.SqlDataReader"
Code:
SqlConnection conn = new SqlConnection("Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;Integrated Security=True");
conn.Open();
SqlCommand sql = new SqlCommand();
sql.CommandText = "SELECT * FROM tblContacts";
sql.Connection = conn;
string strData;
System.Data.SqlClient.SqlDataReader rd;
rd = sql.ExecuteReader();
while (rd.Read()==true)
{
strData = rd.ToString();
}
rd.Close();
What am I missing?
Thanks in advance!
I am attempting to read data from a SQL Server 2005 table. I have the following code below but I'm obviously missing something. When I put a watch on the variable, "strData", the value is the following:
"System.Data.SqlClient.SqlDataReader"
Code:
SqlConnection conn = new SqlConnection("Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;Integrated Security=True");
conn.Open();
SqlCommand sql = new SqlCommand();
sql.CommandText = "SELECT * FROM tblContacts";
sql.Connection = conn;
string strData;
System.Data.SqlClient.SqlDataReader rd;
rd = sql.ExecuteReader();
while (rd.Read()==true)
{
strData = rd.ToString();
}
rd.Close();
What am I missing?
Thanks in advance!