billy111
10-09-2009, 08:09 AM
Hey,
I am trying to add a table using SQL Server 2008, i have managed to do this, but can seem to work out how i can manually add rows into the database. I want to do a simple SELECT to ensure i can connect to the database so i need to enter some test information.
Also I have tried inserting something into the database, and this does not work, i am using the following code:-
protected void Button2_Click(object sender, EventArgs e)
{
string conString = "Data Source=tcp:esql2k801.discountasp.net;Initial Catalog=SQL2008_673062_kids;User ID=SQL2008_673062_kids_user;Password=********;";
SqlConnection empConnection = new SqlConnection(conString);
string insertStatement = "INSERT INTO tbl_users " + "([username], [password]) " + "VALUES ('Test', 'Test')";
SqlCommand insertCommand = new SqlCommand(insertStatement, empConnection);
empConnection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (SqlException ex)
{
}
finally
{
empConnection.Close();
}
}
I think its the connection string thats is wrong, but need your adivce to help me out..
Regards
I am trying to add a table using SQL Server 2008, i have managed to do this, but can seem to work out how i can manually add rows into the database. I want to do a simple SELECT to ensure i can connect to the database so i need to enter some test information.
Also I have tried inserting something into the database, and this does not work, i am using the following code:-
protected void Button2_Click(object sender, EventArgs e)
{
string conString = "Data Source=tcp:esql2k801.discountasp.net;Initial Catalog=SQL2008_673062_kids;User ID=SQL2008_673062_kids_user;Password=********;";
SqlConnection empConnection = new SqlConnection(conString);
string insertStatement = "INSERT INTO tbl_users " + "([username], [password]) " + "VALUES ('Test', 'Test')";
SqlCommand insertCommand = new SqlCommand(insertStatement, empConnection);
empConnection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (SqlException ex)
{
}
finally
{
empConnection.Close();
}
}
I think its the connection string thats is wrong, but need your adivce to help me out..
Regards