Click here to Skip to main content
15,891,889 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
private void btnsubmit_Click(object sender, EventArgs e)
        {

            String connectionString = "server=...........;user id=....;password=....;database=abc";
            SqlConnection thisConnection = new SqlConnection(connectionString);
         
            

            thisConnection.Open();

            String thisQuery = "INSERT INTO abc (ID, Name, ContactNo, Email, Address) VALUES ('" + txtid.Text + "', '" + txtname.Text + "', '" + txtcontact.Text + "', '" + txtemail.Text + "', '" + txtaddress.Text + "')";
            SqlCommand thisCommand = new SqlCommand(thisQuery, thisConnection);
            SqlCommand cmd = new SqlCommand();

            thisCommand.ExecuteNonQuery();
            thisConnection.Close();

        }
Posted
Updated 2-Feb-12 1:13am
v2
Comments
Sridhar Patnayak 2-Feb-12 7:15am    
Question Repeated
Your question link at http://www.codeproject.com/Questions/323788/how-to-connect-database-SQL-windows-authentication -- Please modify existing question

1 solution

String connectionString = "server=.;user id='';password='';database=abc"


. is local server use it as server name just leave blank in place of id and pass like above or belloe

String connectionString = "server=.;user id=;password=;database=abc"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900