Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Server ODBC
#1
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).


thanks.
An old blog on QM coding and automation.

The Macro Hook
#2
In http://www.codeproject.com/database/con ... 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

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

In http://www.carlprothman.net/Default.aspx?tabid=81 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;" & _
"Pwd=myPassword"

in qm is

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

-----

I cannot test how it works.
#3
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")
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 4 Guest(s)