insert directly from application to database

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 33034
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
try
{
using (SqlConnection connect = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand();
command.Connection = connect;
command.CommandText = "insert into customer(name, address) values(@name, @address)";
command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar));
command.Parameters.Add(new SqlParameter("@address", SqlDbType.VarChar));
command.Parameters["@name"].Value = name.Text.ToLower();
command.Parameters["@address"].Value = address.Text.ToLower();
connect.Open();
}
}

Comments or Responses

Login to post response