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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

write back SQL server database when using odbc,but not working???

hi

I write back SQL server database when using odbc,but not working.why?please help me!


Is there something that I am missing on configuration/settings?

Here is my macro below:

sub writerecords

  dim conn,sqlstr

  set conn=CreateObject("ADODB.Connection")  '创建连接对象

  conn.ConnectionString ="DSN=sql1"  ' 

  conn.open   'not working???????

  set table=ActiveDocument.GetSheetObject("TB01") 

  CellRect=ActiveDocument.GetApplication().GetEmptyRect()

  CellRect.Top=0 

  CellRect.Left=0

  CellRect.Width=table.GetColumnCount

  CellRect.Height=table.GetRowCount

  set CellMatrix=table.GetCells(CellRect)

  for RowIter=CellRect.Top+1 to CellRect.Height-1

  zhibao=CellMatrix(RowIter)(0).Text

  xiaxiang=CellMatrix(RowIter)(1).Text

  shangxiang=CellMatrix(RowIter)(2).Text

  sqlstr="insert into tab1(ID,Name,Age) values('"&zhibao&"','"&xiaxiang&"','"&shangxiang&"')"

  conn.execute sqlstr 

  next

  conn.close

  set conn=nothing

  msgbox "写入成功!"

end sub

1 Reply
Miguel_Angel_Baeyens

Hi,

Is the DSN configured to allow read and write operations? Make sure in the "Data Sources (ODBC)" tool that the driver you are using has the permissions correctly.

Apart from that, verify that the user specified in the DSN has permissions to write in the tables.

miguel