Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Implicit conversion from data type varchar to varbinary is not allowed.

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 = 0
CellRect.Left = 0
CellRect.Width = TableBox.GetColumnCount
CellRect.Height = TableBox.GetRowCount
set 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)
next
oConn.Close
Set oConn = Nothing

How to convert?

Labels (1)
1 Reply
Miguel_Angel_Baeyens
Support
Support

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