Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I was looking through your database help for info to create an ODBC connection to a SQL server.
I hit one of the sites that has all those connection types but i'm not sure how to take that and put it into a QM format.

when you get a chance, can you whip up something that'll get me a connection to a sql server via an odbc (i might also need to pass id/password too).

A new blog on QM coding and automation.

The Macro Hook
In ... trings.asp the code is in C/C++ language. Adjacent strings are joined, even if in multiple lines. _T is for Unicode.

strConnect = _T("Provider=sqloledb;Data Source=MyServerName;"
"Initial Catalog=MyDatabaseName;"
"User Id=MyUsername;Password=MyPassword;");

in qm is

Copy      Help
str strConnect = "Provider=sqloledb;Data Source=MyServerName;Initial Catalog=MyDatabaseName;User Id=MyUsername;Password=MyPassword;"
Database db.Open(strConnect)

In the code is in Visual Basic. Strings are joined using &, and lines are joined using _.

oConn.Open "ODBC;Driver={SQL Native Client};" & _
"Server=MyServerName;" & _
"Database=myDatabaseName;" & _
"Uid=myUsername;" & _

in qm is

Copy      Help
Database oConn.Open("ODBC;Driver={SQL Native Client};Server=MyServerName;Database=myDatabaseName;Uid=myUsername;Pwd=myPassword")


I cannot test how it works.
here's what i used to hit an ODBC to SQL Server db if you have the ODBC setup in your "Data Sources (ODBC)" under the "System DSN"

Database oConn.Open("DSN=name of the odbc connection here")
A new blog on QM coding and automation.

The Macro Hook

Forum Jump:

Users browsing this thread: 1 Guest(s)