在update语句中未在cm.excutenonquery语法错误处处理oledbexcption [英] oledbexcption unhandled at cm.excutenonquery syntax error in update statement
本文介绍了在update语句中未在cm.excutenonquery语法错误处处理oledbexcption的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<pre lang="vb">Imports System.Data.OleDb
Public Class updatefarmer
Dim co As OleDbConnection
Dim cm As OleDbCommand
Dim dr As OleDbDataReader
Private Sub updatefarmer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GroupBox1.Visible = False
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Label2.Text = "enter no"
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Label2.Text = "enter name "
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
co = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\varsha2011\plotdetails\plotdetails\farmerinfo.mdb;")
co.Open()
cm = New OleDbCommand()
Dim str As String = " "
Dim table As String = ""
If RadioButton1.Checked = True Then
str = "select * from farmerinfo where fileno = " & " " & CInt(txtse.Text) & " "
End If
If RadioButton2.Checked = True Then
str = "select * from farmerinfo where farmername = " & " ''" & txtse.Text & " '' "
End If
cm.Connection = co
cm.CommandText = str
cm.CommandType = CommandType.Text
dr = cm.ExecuteReader()
If (dr.Read) Then
GroupBox1.Visible = True
txtfile.Text = dr("fileno").ToString()
txtname.Text = dr("farmername").ToString()
txtaddress.Text = dr("address").ToString()
txtloc.Text = dr("location").ToString()
txtgroup.Text = dr("group").ToString()
txtplot.Text = dr("plotno").ToString()
txtcontact.Text = dr("contact").ToString()
txtmobile.Text = dr("mobile").ToString()
Else
MessageBox.Show("record not found please retry ", "failure", MessageBoxButtons.OK)
End If
End Sub
Private Sub txtsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsave.Click
co = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\varsha2011\plotdetails\plotdetails\farmerinfo.mdb;")
co.Open()
GroupBox1.Visible = False
Dim str2 As String = " "
str2 = "UPDATE farmerinfo SET fileno=@fileno,farmername = @farmername ,address=@address,location= @location ,group=@group ,plotno=@plotno ,contact=@contact,mobile=@mobile WHERE fileno =@fileno ;"
cm = New OleDbCommand(str2, co)
cm.Parameters.AddWithValue("@fileno", txtfile.Text)
cm.Parameters.AddWithValue("@farmername ", txtname.Text)
cm.Parameters.AddWithValue("@address", txtaddress.Text)
cm.Parameters.AddWithValue("@location", txtloc.Text)
cm.Parameters.AddWithValue("@group", txtgroup.Text)
cm.Parameters.AddWithValue("@plotno", txtplot.Text)
cm.Parameters.AddWithValue("@contact", txtcontact.Text)
cm.Parameters.AddWithValue("@mobile", txtmobile.Text)
cm = New OleDbCommand(str2, co)
cm.ExecuteNonQuery()
MessageBox.Show("updates successfully", "update", MessageBoxButtons.OK)
co.Close()
txtse.Focus()
End Sub
End Class
如何解决:
在更新语句中cm.excutenonquery语法错误未处理的oledbexcption
How to resolve:
oledbexcption unhandled at cm.excutenonquery syntax error in update statement
推荐答案
在此处查看以下链接: ^ ]
下次,请花一些时间来提出您的问题.您在尝试什么以及如何出错.
Look at these links here: Google Search result for the same[^]
Next time, spend some more time in formulating your question. What were your trying and how you got an error.
这篇关于在update语句中未在cm.excutenonquery语法错误处处理oledbexcption的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文