I've created a windows application to display the data from SQL database to a gridview in a windows application. I used VB.net and SQL server to do that. While using where condition in the sql query I got the values which satisfies given data. Now I need to update the shown data. For that I used the sql query Update columnName = value where (the condition). the column name and value are got from the user using a textbox. When i used the query in Sql, it works fine and the value gets updated in database. But, When I run the same in VB code it doesn't gets updated in the windows application. I doesn't get it, and the assigned time for it runs beyond my watch time. Please, help me someone. Thanks in advance.Here I attach the code.
\ the code starts here \
Private Sub Btn_Edit_Click(sender As Object, e As EventArgs) Handles btn_Update.Click
cmdupdate.Connection = connection
connection.Open()
'table.Rows.Clear()
'table.Columns.Clear()
cmdupdate.CommandText = "update tblWebaccessErrorTrack set @columnName = @editData where IssueDateTime between @frmdate and @todate and ErrorDetails like '%' + @errorDetails + '%' and ClientIpaddress like '%'+ @IpAddress + '%' and ResponseStatus like '%'+ @responseStatus + '%' and TicketNo like '%' + @ticketNo + '%' select * from tblWebaccessErrorTrack"
table.Clear()
'"UPDATE tblWebaccessErrorTrack
' SET
' @columnName = @editData"
'"sp_Updatedata"
'Update tblWebaccessErrorTrack set TicketNo=202010 select * from tblWebaccessErrorTrack
'cmdupdate.CommandType = CommandType.StoredProcedure
cmdupdate.Parameters.Add("@frmdate", SqlDbType.DateTime).Value = frm_DateTimePicker.Text
cmdupdate.Parameters.Add("@todate", SqlDbType.DateTime).Value = to_DateTimePicker.Text
cmdupdate.Parameters.Add("@errorDetails", SqlDbType.NVarChar).Value = txtErrorDetails.Text
cmdupdate.Parameters.Add("@IpAddress", SqlDbType.NVarChar).Value = txtClientIp.Text
cmdupdate.Parameters.Add("@responseStatus", SqlDbType.NVarChar).Value = txtResponseStatus.Text
cmdupdate.Parameters.Add("@ticketNo", SqlDbType.NVarChar).Value = txtTicketNo.Text
cmdupdate.Parameters.Add("@columnName", SqlDbType.NVarChar).Value = Columnvalue '//column name
cmdupdate.Parameters.Add("@editData", SqlDbType.NVarChar).Value = txtEditdata.Text '//Data we give
adapter = New SqlDataAdapter(cmdupdate)
adapter.Fill(table)
adapter.Update(table)
DataGridView1.DataSource = table
'adapter.Fill(table)
'table.Clear()
'cmdupdate.CommandText = "select * from tblWebaccessErrorTrack" 'where IssueDateTime between @frmdate and @todate and ErrorDetails like '%' + @errorDetails + '%' and ClientIpaddress like '%'+ @IpAddress + '%' and ResponseStatus like '%'+ @responseStatus + '%' and TicketNo like '%' + @ticketNo + '%'"
'adapter = New SqlDataAdapter(cmdupdate)
'adapter.Fill(table)
'adapter.Update(table)
'DataGridView1.DataSource = table
''adapter.Fill(table)
''cmdupdate.Parameters.Clear()
'table.Clear()
connection.Close()
cmd.Parameters.Clear()
End Sub`enter code here`
- the character(') present in front of some line represents commented line.