[RESOLVED] data type error
can some one plz help me out the following code is giving an error as data type mismatch in crieteria expressionat line
Set rs = conn.Execute(str)
i am stuck plz help
VB Code:
ConvertTxtToExcel(lSourceFile As String)
Set myXLObj = CreateObject("Excel.Application")
myXLObj.Visible = True ' to make the Excel app visible
On Error GoTo 0
With myXLObj
.Workbooks.OpenText FileName:=lSourceFile, DataType:=XLDELIMITED, _
TextQualifier:=XLDOUBLEQUOTE, semicolon:=True, _
FieldInfo:=Array(1, 2)
End With
Dim i As Integer
Dim j As Integer
Dim a As String
Dim str As String
Dim k As String
i = 5
j = 1
While i < 180
While j <= 7
If j = 1 Then
k = "notice"
ElseIf j = 2 Then
k = "are1no"
ElseIf j = 3 Then
k = "Date"
ElseIf j = 4 Then
k = "pname"
ElseIf j = 5 Then
k = "IName"
ElseIf j = 6 Then
k = "tariff"
ElseIf j = 7 Then
k = "duty"
End If
Set conn = New ADODB.Connection
conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\excel\xldata.mdb;Persist Security Info=False")
a = Cells(i, j).Value
'str = " update [data] set [" & k & "] = '" & a & "' where [sno] = '" & i & "'"
str = "UPDATE [data] SET " & k & "= '" & a & "' WHERE sno = '" & i & "' "
Set rs = conn.Execute(str)
j = j + 1
Wend
i = i + 1
Wend
End Sub
Re: [RESOLVED] data type error
glad you got it fixed. also note that you can change the types in vbcode. for example, if you were using a string and you wanted to change to an integer, you can use CInt(). there are many of these change types in VB6.