Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
When I insert data into database by Macro, I got this
"Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query."
dim sConn, oConn
Set oConn = CreateObject("ADODB.Connection")
sConn = "******************************************************************"
set TableBox = ActiveDocument.GetSheetObject( "CH39" )CellRect = ActiveDocument.GetApplication().GetEmptyRect()CellRect.Top = 0CellRect.Left = 0CellRect.Width = TableBox.GetColumnCountCellRect.Height = TableBox.GetRowCountset CellMatrix = TableBox.GetCells( CellRect )for RowIter=1 to CellRect.Height-1 vFinancialClass=CellMatrix(RowIter)(0).Text vPayment=CellMatrix(RowIter)(1).Text sSQL="insert into dbo.tmp_temp(FinancialClass) values('"&vPayment&"')" oConn.Execute(sSQL)nextoConn.CloseSet oConn = Nothing
How to convert?
Hi,
First make sure what type of field FinancialClass is (varchar, varbinary, char, int, etc)
Second, modify the INSERT query to adapt to that data type:
sSQL = "INSERT INTO dbo.tmp_temp (FinancialClass) VALUES (CAST('" & vPayment & "' AS VARCHAR(100)))"
I'm using VARCHAR(100) as an example, your database may be different.
Hope that helps.
Miguel Angel Baeyens
BI Consultant
Comex Grupo Ibérica