data type mismatch. (1 Viewer)

sid310

New member
Local time
Today, 14:51
Joined
Oct 18, 2011
Messages
1
hi guys....im new to this form and access and vb.net......i am creating a database for my company..... everything works fine but while editing data i get error as data type mismatch... i am using vb 2010 and access 2007.... i am posting a bit of my code....please help me....thanks in advance...



Public Function savefile(ByVal callcell As Integer, ByVal name As String, ByVal loc As String)
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
dbProvider = "Provider =Microsoft.ACE.OLEDB.12.0;"


dbSource = locationdb
con.ConnectionString = dbProvider & dbSource
con.Open()
Dim namefile As String
Dim placefile As String
namefile = ""
placefile = ""
namefile = name
placefile = loc
MsgBox(name & " " & loc)
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
sql = "SELECT * FROM Main_1"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "inter")
'Dim cb As New OleDb.OleDbCommandBuilder(da)
'ds.Tables("inter").Rows(refcal).Item(22) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(23) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(24) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(25) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(26) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(27) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(28) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(29) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(30) = "tcib"
'ds.Tables("inter").Rows(refcal).Item(31) = "tcib"
Select Case callcell
Case 1
MsgBox("entered case 1")
MsgBox("case" & callcell & "name" & name & "loc" & loc)
If (namefile = "") Then
ds.Tables("inter").Rows(refcal).Item(22) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(22) = namefile
End If
If (placefile = "") Then
ds.Tables("inter").Rows(refcal).Item(23) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(23) = placefile
End If


' Dim objCmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("UPDATE Main_1 WHERE ( 1 = 1 )) set(23=" & namefile & ",24=" & placefile & ",", New OleDb.OleDbConnection(dbProvider & dbSource))






Case 2
If (namefile = "") Then
ds.Tables("inter").Rows(refcal).Item(24) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(24) = namefile
End If

If (placefile = "") Then
ds.Tables("inter").Rows(refcal).Item(25) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(25) = placefile
End If

Case 3
If (namefile = "") Then
ds.Tables("inter").Rows(refcal).Item(26) = "tcib"
Else

ds.Tables("inter").Rows(refcal).Item(26) = namefile
End If
If (placefile = "") Then
ds.Tables("inter").Rows(refcal).Item(27) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(27) = placefile
End If
Case 4
If (namefile = "") Then
ds.Tables("inter").Rows(refcal).Item(28) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(28) = namefile
End If
If (placefile = "") Then
ds.Tables("inter").Rows(refcal).Item(29) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(29) = placefile
End If
Case 5
If (namefile = "") Then
ds.Tables("inter").Rows(refcal).Item(30) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(30) = namefile
End If
If (placefile = "") Then
ds.Tables("inter").Rows(refcal).Item(31) = "tcib"
Else
ds.Tables("inter").Rows(refcal).Item(31) = placefile
End If
End Select
con.Close()
con.Open()

Try
Dim cm As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da)
da.UpdateCommand = cm.GetUpdateCommand()
da.InsertCommand = cm.GetInsertCommand()

Catch ex As Exception
MsgBox(ex.Message)
End Try


Try
da.Update(ds, "inter") /// this is the problem i am getting.....
Catch ex As Exception
MsgBox(ex.Message)
End Try



MsgBox("updated")
con.Close()
Return Nothing
End Function
 

Users who are viewing this thread

Top Bottom