Hi all:
I keep getting this error:
"unable to cast object of type 'System.Int32' to type 'System.String'"
What does it mean, this is my code
Thanks
I keep getting this error:
"unable to cast object of type 'System.Int32' to type 'System.String'"
What does it mean, this is my code
Code:
SqlConnection conn = new SqlConnection("Server=xxxx;Database=xxx;User ID=xxx;Password=xxxxxx");
//Create A Command (the query or store proc you will use)
SqlCommand sqlComm = new SqlCommand("Select LocationId,SF_STREET,SF_City,SF_State,SF_Zip from SF_Locations where LocationId=15", conn);
//Open the connection
conn.Open();
//Execute the command(query)
SqlDataReader r = sqlComm.ExecuteReader();
while (r.Read())
{
this.textBoxAddress.Text = r.GetString(2);
//I even tried this.textBoxAddress.Text=r["SF_State"]); did not work
}
// Close the reader and the connection
r.Close();
conn.Close();