| | |
Please tell me what is wrong in my update code
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Please Check the code and reply what is wrong in the update code
Try block is executed successfully........but it is not being updated.
Public Class Form3
Dim cn As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=attend_ap; User=root;Password=;")
Dim cmd, cmd2 As Odbc.OdbcCommand
Dim adp, adp2 As Odbc.OdbcDataAdapter
Dim ds, ds2 As New DataSet
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Form1.Close()
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.Open()
cmd = New Odbc.OdbcCommand
cmd.Connection = cn
cmd.CommandText = "Select * from " & Form1.TextBox2.Text & "_att"
ds = New DataSet
adp = New Odbc.OdbcDataAdapter(cmd)
Try
adp.Fill(ds, Form1.TextBox2.Text & "_att")
Catch ex As Exception
MsgBox("Invalid Table name")
Me.Close()
End Try
Me.DataGridView1.DataSource = ds
Me.DataGridView1.DataMember = Form1.TextBox2.Text & "_att"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub Form3_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
cmd2 = New Odbc.OdbcCommand
cmd2.Connection = cn
cmd2.CommandText = "Select * from " & Form1.TextBox2.Text & "_att"
ds2 = New DataSet
adp2 = New Odbc.OdbcDataAdapter(cmd2)
Try
adp2.Fill(ds2, Form1.TextBox2.Text & "_att")
Catch ex As Exception
MsgBox("Invalid Table name")
Me.Close()
End Try
Me.DataGridView1.DataSource = ds2
Me.DataGridView1.DataMember = Form1.TextBox2.Text & "_att"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim cmdbuilder As New Odbc.OdbcCommandBuilder(adp)
' Dim cmdbuilder2 As New Odbc.OdbcCommandBuilder(adp2)
Try
i = adp.Update(ds, Form1.TextBox2.Text & "_att")
' cmd.ExecuteNonQuery()
' i = adp2.Update(ds2, Form1.TextBox2.Text & "_att")
MsgBox("records updated sucessfully")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
Me.Label2.Text = Form1.TextBox2.Text
End Sub
End Class
Try block is executed successfully........but it is not being updated.
Public Class Form3
Dim cn As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=attend_ap; User=root;Password=;")
Dim cmd, cmd2 As Odbc.OdbcCommand
Dim adp, adp2 As Odbc.OdbcDataAdapter
Dim ds, ds2 As New DataSet
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Form1.Close()
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.Open()
cmd = New Odbc.OdbcCommand
cmd.Connection = cn
cmd.CommandText = "Select * from " & Form1.TextBox2.Text & "_att"
ds = New DataSet
adp = New Odbc.OdbcDataAdapter(cmd)
Try
adp.Fill(ds, Form1.TextBox2.Text & "_att")
Catch ex As Exception
MsgBox("Invalid Table name")
Me.Close()
End Try
Me.DataGridView1.DataSource = ds
Me.DataGridView1.DataMember = Form1.TextBox2.Text & "_att"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub Form3_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
cmd2 = New Odbc.OdbcCommand
cmd2.Connection = cn
cmd2.CommandText = "Select * from " & Form1.TextBox2.Text & "_att"
ds2 = New DataSet
adp2 = New Odbc.OdbcDataAdapter(cmd2)
Try
adp2.Fill(ds2, Form1.TextBox2.Text & "_att")
Catch ex As Exception
MsgBox("Invalid Table name")
Me.Close()
End Try
Me.DataGridView1.DataSource = ds2
Me.DataGridView1.DataMember = Form1.TextBox2.Text & "_att"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim cmdbuilder As New Odbc.OdbcCommandBuilder(adp)
' Dim cmdbuilder2 As New Odbc.OdbcCommandBuilder(adp2)
Try
i = adp.Update(ds, Form1.TextBox2.Text & "_att")
' cmd.ExecuteNonQuery()
' i = adp2.Update(ds2, Form1.TextBox2.Text & "_att")
MsgBox("records updated sucessfully")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
Me.Label2.Text = Form1.TextBox2.Text
End Sub
End Class
For the code i have posted there is no error message
it shows updated successfully....but it is not updating it
if i comment the whole form3_visiblechanged function then error
in 77th line i.e
i = adp.Update(ds, Form1.TextBox2.Text & "_att")
in the try block of the button1_click
error message is:
dynamic generation for the update command is not supported against a select command that does not return any key column information.
it shows updated successfully....but it is not updating it
if i comment the whole form3_visiblechanged function then error
in 77th line i.e
i = adp.Update(ds, Form1.TextBox2.Text & "_att")
in the try block of the button1_click
error message is:
dynamic generation for the update command is not supported against a select command that does not return any key column information.
![]() |
Similar Threads
- Please help with JSP mysql update query (JSP)
- update sql d/b with session / c# (ASP.NET)
- Open\Save code (Visual Basic 4 / 5 / 6)
- Classic sql update question (ASP)
- help!! update mysql problem (MySQL)
- Can any1 tell me whatz wrong in this program...this does not show the output!!! (C++)
- Can't update a textbox in Visual C++ (C++)
- Something wrong with my code, why Junk character appears? (C)
- How to develop a new program (C++)
- Need help with DirectX code (C)
Other Threads in the VB.NET Forum
- Previous Thread: WSDL SOAP
- Next Thread: Newbie need help with filtering/showing data
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google gridview html images input insert intel internet listview mobile monitor net networking objects open output panel passingparameters pdf picturebox port position print printing problem remove save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





