标题:未处理的“System.Data.OleDb.OleDbException 达人进来帮下忙
取消只看楼主
wjq
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-4-8
 问题点数:0 回复次数:1 
未处理的“System.Data.OleDb.OleDbException 达人进来帮下忙

Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
If btnadd.Text = "Add" Then
txtid.Text = ""
txtname.Text = ""
txttelno.Text = ""
txtaddress.Text = ""
txtemail.Text = ""
btnadd.Text = "Confirm"
MessageBox.Show("Add the information and then Click the confirm", "check", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If


If btnadd.Text = "Confirm" Then
Dim currentPos As Integer = ps.Position
If MessageBox.Show("Are you sure to add", "Confirm", MessageBoxButtons.OKCancel) = DialogResult.OK Then
Dim id As String = "'" & txtid.Text & "'"
Dim name As String = "'" & txtname.Text & "'"
Dim telno As String = "'" & txttelno.Text & "'"
Dim Address As String = "'" & txtaddress.Text & "'"
Dim Email As String = "'" & txtemail.Text & "'"

Dim addstr As String
addstr = "insert into Company(companyID,companyName,telNo,address,email) values("
addstr = addstr & id & "," & name & "," & telno & "," & Address & "," & Email & ")"
OleDbConnection1.Open()
OleDbDataAdapter1.InsertCommand.CommandText = addstr
OleDbDataAdapter1.InsertCommand.ExecuteNonQuery()这句错误
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
ps.Position = ps.Count - 1
OleDbConnection1.Close()
Else
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
ps.Position = currentPos
End If
btnadd.Text = "Add"

End If
End Sub

请达人帮看看哪里错了.我是新手..一直找不出哪里错了.

搜索更多相关主题的帖子: System Data OleDb Text 
2007-04-08 18:22
wjq
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-4-8
得分:0 
addstr = "insert into Company(companyID,companyName,telNo,address,email) values(" & id & ",'" & name & "'," & telno & ",'" & Address & "','" & Email & "')" 改成这样有单引号的还是不行...
哪位高手帮改下正确的sql insert 语句.谢谢.
2007-04-11 20:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-130183-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.255511 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved