I have created the web page using asp.net and also database using Sql server want to input through text box from asp.net and insert the same to database i am new to this please guide (created data base using windows authentication in sql server)
I have created the web page using asp.net and also database using Sql server want to input through text box from asp.net and insert the same to database i am new to this please guide (created data base using windows authentication in sql server)
1) Create an SqlConnection object. Supply a connection string to the object
SqlConnection cn = new SqlConnection("server=YourServer; Database=YourDB; Integrated Security = True" );
2) Create a command object to hold and execute your query
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "Your Query Here";
3)Open the connection:
cn.Open();
4)Execute your query
cmd.ExecuteReader(); //if the query retrieves a record set
cmd.ExecuteNonQuery(); //if the query is a Data modification SQL
5) Close the connection
cn.Close();
Hope this helps.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks