Home » U++ Library support » U++ SQL » MS SQL Server connection possible?
Re: MS SQL Server connection possible? [message #8459 is a reply to message #8371] |
Mon, 12 March 2007 10:22  |
|
ODBC is too much complicated at low level and there is no wrraper for it in upp yet. But there is one for oledb. If you want to connect to sql server you must prepare so called connection string eg:
#include <OleDB/OleDB.h>
#include <Core/Core.h>
String ConnectionString(String name, String host, String port, String login, String pass, bool trusted = true)
{
String conn = "Provider=SQLNCLI;";
String p;
if(!port.IsEmpty())
p = "," + port;
conn += Format("Server=%s%s;", host, p);
conn += Format("Database=%s;", name);
if(trusted)
conn += "Trusted_Connection=yes;";
if(!login.IsEmpty())
conn += Format("User ID=%s;", login);
if(!pass.IsEmpty())
conn += Format("Password=%s;", pass);
return conn;
}
void main()
{
OleDBSession db;
if(db.OpenProp(ConnectionString("mydatabese", "localhost\SQLEXPRESS", "", "uno", "mypass")))
{
// Connection established. Do whatever you want!
}
}
I will prepare a better example soon which will be available in upp reference.
[Updated on: Mon, 12 March 2007 10:23] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jul 20 00:00:56 CEST 2025
Total time taken to generate the page: 0.05876 seconds
|