____________ www.flickr.com/photos/psdesigner/
------------------------------------------------ Learn throughout life
protected void BtnSubmit_Click(object sender, EventArgs e) { // Get Connection String ConnectionStringSettings conn = System.Configuration.ConfigurationManager.ConnectionStrings("YourDB"); // Create connection object SqlConnection connection = new SqlConnection(conn.ToString); SqlCommand command = connection.CreateCommand(); try { // Open the connection. connection.Open(); // Execute the insert command. command.CommandText = ("INSERT INTO Your_Tbl(FirstName,LastName) VALUES(\'" + (this.TxtFirstName.Text + ("\',\'" + (this.TxtLastName.Text + ("\',\'" )))); command.ExecuteNonQuery(); } finally { // Close the connection. connection.Close(); } // Display success message. MsgBox("Insertion Successful"); }
<connectionStrings> <add name="YourDB" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings>
--------------------------------------- Live the life you've dreamed Regards MADHU
Login to post response