WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: krasdude on September 06, 2016, 10:03:49 AM

Title: ODBC DSN Less Help
Post by: krasdude on September 06, 2016, 10:03:49 AM
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
Title: Re: ODBS DSN Less Help
Post by: JTaylor on September 06, 2016, 10:11:33 AM
Search the Tech Database for examples?

Jim
Title: Re: ODBS DSN Less Help
Post by: td on September 06, 2016, 10:13:38 AM
And here:

https://www.connectionstrings.com/ (https://www.connectionstrings.com/)
Title: Re: ODBC DSN Less Help
Post by: krasdude on September 06, 2016, 10:25:21 AM
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
Title: Re: ODBC DSN Less Help
Post by: krasdude on September 06, 2016, 10:54:22 AM
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)
Title: Re: ODBC DSN Less Help
Post by: krasdude on September 06, 2016, 11:06:56 AM
ok, never mind ... thanks all.  I figured it out
Title: Re: ODBC DSN Less Help
Post by: JTaylor on September 06, 2016, 11:11:27 AM
In case you find it useful....search in the TechDatabase for:

ADO SQLOLEDB Example


Jim