条件表达式中的数据类型不匹配,从datagridview向访问表添加数据

时间:2015-02-09 18:23:45

标签: database datagridview mismatch

我似乎无法让我的代码工作。我一直在标准表达式中遇到“数据类型不匹配”的问题。错误。谁能告诉我我做错了什么。我试图将我的datagridview中的所有内容添加到访问表。这是我的代码。

Dim connect As New OleDbConnection
connect.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../Database.mdb")
connect.Open()

Dim str As String
str = "DELETE * FROM Tickets"
Dim cmdd As OleDbCommand = New OleDbCommand(str, connect)

cmdd.ExecuteNonQuery()
cmdd.Dispose()

Dim AssignedCSR, Network, TicketNumber, DateReceived As String
For p as Integer = 0 To Me.DataGridView1.Rows.Count - 1
   AssignedCSR = Me.DataGridView1.Rows(p).Cells(0).Value.ToString()
   Network = Me.DataGridView1.Rows(p).Cells(1).Value.ToString()
   TicketNumber = Me.DataGridView1.Rows(p).Cells(2).Value.ToString()
   DateReceived = Me.DataGridView1.Rows(p).Cells(3).Value.ToString()

   str = "INSERT INTO Tickets(AssignedCSR,Network,TicketNumber,DateReceived) VALUES('" & AssignedCSR & "','" & Network & "','" & TicketNumber & "','" & DateReceived & "')"
   cmdd = New OleDbCommand(str, connect)
   cmdd.ExecuteNonQuery 'This is where I am getting the error
   cmdd.Dispose()
Next
connect.Close()

0 个答案:

没有答案