Click here to Skip to main content
15,899,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
cmd = New SqlCommand("insert into Login1 values" & "(" & "'" & TextBox1.Text & "'" & "," & "'" & TextBox2.Text & "'" & "," & "'" & TextBox3.Text & "'" & "," & TextBox4.Text & "," & TextBox5.Text & "," & "'" & TextBox6.Text & "'" & "," & "'" & TextBox7.Text & "'" & ")", cn)

        cmd.ExecuteNonQuery()
        


       adp.Fill(ds, "Login1")
        MsgBox("Record Inserted....")
        ds.Clear()



while I fire this query then record has been inserted twice in my sql database. I can't recognize this bug.
so please help me in this basic stuff.
Posted
Updated 27-Sep-11 4:43am
v2

1 solution

try to write only for save values

cmd = New SqlCommand("insert into Login1 values" & "(" & "'" & TextBox1.Text & "'" & "," & "'" & TextBox2.Text & "'" & "," & "'" & TextBox3.Text & "'" & "," & TextBox4.Text & "," & TextBox5.Text & "," & "'" & TextBox6.Text & "'" & "," & "'" & TextBox7.Text & "'" & ")", cn)
cmd.ExecuteNonQuery()


its not a good practice to save values as you are doing,always try to write Parameterized Insert Command.
take a look Database Parameterized Insert Tutorial[^]
 
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