ODBC DSN Less Help

Started by krasdude, September 06, 2016, 10:03:49 AM

Previous topic - Next topic

krasdude

I am sure this question has been answered somewhere but I've been away from programming for a year and need a fresher.  I am unable to create File or System DSN  due to Virtual machines and restrictions placed on them.  I need to (a) either use  an in-line connection to MS SQL servers (i.e. Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;) or dynamically create a DSN file and connect or (c) something else.  I think I've done this before but I was unable to take scripts when left old company.   any suggestions on ways to solve my issue???

Thanks

JTaylor

Search the Tech Database for examples?

Jim

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

krasdude

I did go there but I guess I must be not programming it right.  is there an example of DSN less winbatch code?  I must have missed it

krasdude

I am using thsi code (xxxx are filled in)

hdbc = qAllocConnect(henv)
If hdbc == -1
  retcode = qLastCode()
  Message("qAllocConnect failed", retcode)
  Exit
Endif
     
oConnect="Driver={SQL Server};Server=xxxx\Sqlexpress;Database=xxxx;User ID=xxxx;Password=;Trusted_Connection=True;"
ret=qDriverCon(hdbc, cConnect, 0); don't prompt user.

but get this error message (attached)

krasdude

ok, never mind ... thanks all.  I figured it out

JTaylor

In case you find it useful....search in the TechDatabase for:

ADO SQLOLEDB Example


Jim