April 26, 2009

Insert string to Sql Database using ADO.NET


public void InsertStringToTable(string t1)
{
SqlConnection connection = new SqlConnection(constring);
SqlCommand command;
command = new SqlCommand ("INSERT INTO TableName(Name)
VALUES('"
+ t1 + "')", connection);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}

No comments: