Trying to upload a database from an excel file.
All is going well until it gets to a value which is given in this format : 312,45
Every other values are integer values so the problem only comes out when it reaches a double value.
So it works like this:
I have my variables which are containing the numbers dim-ed as double.
Then the program with some loops and ifs it inserts the value to the sql database.
Every time I insert a whole line so every field have its own variables in excel in order to give them to sql.
The part of the code which does the sql insert:
So the problem occurs when it reaches a value in the excel file which is not integer but double (so its not in the format like the other numbers but in this format: 123,13 with comma in it) and it reaches the cn.Execute strSQL part of the code.
The error it gives is:
Run-time error '2147467259 (80004005)
Automation error
I've had an error like this before, but I've solved it with changing the apostrophes in the secont strSQL!
Also in the sql table I have those fields which contains the numbers declared as double.
So I don't know what could cause the problem.
Is there anyone who can help?
If something is not clear I'll explain it more, just ask!
All is going well until it gets to a value which is given in this format : 312,45
Every other values are integer values so the problem only comes out when it reaches a double value.
So it works like this:
I have my variables which are containing the numbers dim-ed as double.
Then the program with some loops and ifs it inserts the value to the sql database.
Every time I insert a whole line so every field have its own variables in excel in order to give them to sql.
The part of the code which does the sql insert:
Code:
Dim v_irodanev, v_valutaneve As String Dim v_eladas As Double
Dim v_vetel As Double
Dim i As Integer
Dim k As Integer
i = 2
Do While ws.Range("A" & i).Value <> ""
If ws.Range("A" & i).Value <> "***" Then
If ws.Range("A" & i).Value = "#" Then
v_irodanev = ws.Range("B" & i).Value
Else
v_valutaneve = ws.Range("A" & i).Value 'itt megkapjuk a valuta nevét
v_vetel = ws.Range("B" & i).Value
v_eladas = ws.Range("C" & i).Value
strSQL = "INSERT INTO arfolyam (irodanev,valutanev,eladas,vetel,datum)"
strSQL = strSQL & "VALUES (""" & v_irodanev & """,""" & v_valutaneve & """,""" & v_eladas & """,""" & v_vetel & """,'" & datumido & "')"
Debug.Print strSQL
cn.Execute strSQL, adExecuteNoRecords
End If
End If
i = i + 1
Loop
So the problem occurs when it reaches a value in the excel file which is not integer but double (so its not in the format like the other numbers but in this format: 123,13 with comma in it) and it reaches the cn.Execute strSQL part of the code.
The error it gives is:
Run-time error '2147467259 (80004005)
Automation error
I've had an error like this before, but I've solved it with changing the apostrophes in the secont strSQL!
Also in the sql table I have those fields which contains the numbers declared as double.
So I don't know what could cause the problem.
Is there anyone who can help?
If something is not clear I'll explain it more, just ask!