Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Try
            If con.State <> ConnectionState.Open Then con.Open()
            cmd.CommandText = " UPDATE ALLUGTAMIL SET '" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & TextBox15.Text & "','" & TextBox16.Text & "','" & TextBox17.Text & "','" & TextBox18.Text & "','" & TextBox19.Text & "','" & TextBox20.Text & "','" & TextBox21.Text & "','" & TextBox22.Text & "','" & TextBox23.Text & "','" & TextBox24.Text & "','" & TextBox25.Text & "','" & TextBox26.Text & "','" & TextBox27.Text & "','" & TextBox28.Text & "','" & TextBox29.Text & "','" & TextBox30.Text & "','" & TextBox31.Text & "','" & TextBox32.Text & "','" & TextBox33.Text & "','" & TextBox34.Text & "','" & TextBox35.Text & "','" & TextBox36.Text & "','" & TextBox37.Text & "','" & TextBox38.Text & "','" & TextBox39.Text & "','" & TextBox40.Text & "','" & TextBox41.Text & "','" & TextBox42.Text & "','" & TextBox43.Text & "','" & TextBox44.Text & "','" & TextBox45.Text & "','" & TextBox46.Text & "','" & TextBox47.Text & "','" & TextBox48.Text & "','" & TextBox49.Text & "','" & TextBox50.Text & "','" & TextBox51.Text & "','" & TextBox52.Text & "','" & TextBox53.Text & "','" & TextBox54.Text & "','" & TextBox55.Text & "','" & TextBox56.Text & "','" & TextBox57.Text & "','" & TextBox58.Text & "','" & TextBox59.Text & "','" & TextBox60.Text & "','" & TextBox61.Text & "','" & TextBox62.Text & "','" & TextBox63.Text & "','" & TextBox64.Text & "','" & TextBox65.Text & "','" & TextBox66.Text & "','" & TextBox67.Text & "','" & TextBox68.Text & "','" & TextBox69.Text & "','" & TextBox70.Text & "','" & TextBox71.Text & "','" & TextBox72.Text & "','" & TextBox73.Text & "','" & TextBox74.Text & "','" & TextBox75.Text & "','" & TextBox76.Text & "','" & TextBox77.Text & "','" & TextBox78.Text & "','" & TextBox79.Text & "','" & TextBox80.Text & "','" & TextBox81.Text & "','" & TextBox82.Text & "','" & TextBox83.Text & "','" & TextBox84.Text & "','" & TextBox85.Text & "','" & TextBox86.Text & "','" & TextBox87.Text & "','" & TextBox88.Text & "','" & TextBox89.Text & "','" & TextBox90.Text & "','" & TextBox91.Text & "','" & TextBox92.Text & "','" & TextBox93.Text & "','" & TextBox94.Text & "','" & TextBox95.Text & "','" & TextBox96.Text & "','" & TextBox97.Text & "','" & TextBox98.Text & "','" & TextBox99.Text & "','" & TextBox100.Text & "','" & TextBox101.Text & "','" & TextBox102.Text & "','" & TextBox103.Text & "','" & TextBox104.Text & "','" & TextBox105.Text & "','" & TextBox106.Text & "','" & TextBox107.Text & "','" & TextBox108.Text & "','" & TextBox109.Text & "' WHERE  REG_NO = '" & TextBox1.Text & "' "
            If cmd.ExecuteNonQuery > 0 Then
                MsgBox("STUDENT MARKS RECORD UPDATED")
                Clear_Text()
            Else
                MsgBox("STUDENT RECORD NOT FOUND")
                Clear_Text()
            End If
            If con.State <> ConnectionState.Closed Then con.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information)
        End Try
    End Sub
Posted
Updated 28-Aug-13 18:59pm
v2
Comments
[no name] 29-Aug-13 1:00am    
What is the error..??where you are getting the error..??improve question and provide the details...
muneebalikiyani 29-Aug-13 1:01am    
Hi, highlight the statement causing error .
Thanks7872 29-Aug-13 1:04am    
Where you saw the high lighted statement? Let the OP clarify it.The question is not by you then how can you assume error?
muneebalikiyani 29-Aug-13 1:15am    
Huh...! read carefully . i said Highlight the statement that is causing error.
Thanks7872 29-Aug-13 1:17am    
But why are you making baseless statements when question is not by you? I read carefully and i found no high lighted statement. Can you comment on which statement is highlighted here?

1 solution

Hello Member,

The correct syntax for UPDATE statement is
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

From your code it seems that your update statement is not getting formed in a correct manner. Also I won't recommend to use this kind of SQL generation in your application as it will open your application for SQL Injection attacks. Use Prepared Statements[^] instead.

Regards,
 
Share this answer
 
Comments
Thanks7872 29-Aug-13 1:11am    
+5..! From the question content,i think OP needs some practice regarding all this stuff.
Prasad Khandekar 29-Aug-13 1:17am    
Thank's Rohan!

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