Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to connect with SQL Server 2

Status
Not open for further replies.

LordOfCode

Programmer
Feb 26, 2000
66
US

Currentrly I am programming a TDataAccessor class for an SQL Server 2000 database usin Borland C++ Builder Enterprise Edition (v6.0).

I am using TDatabase class in the DBTables.hpp. In order to connect to the database I am using ODBC, however, I do not want to use a trusted connection (Windows Authentication).

this is part of my code

Code:
database->loginPrompt = false;
database->Params->add("uid=sa");
database->Params->add("pwd=development");
database->AliasName="SecurityODBC";
database->DatabaseName="Security";
database->Exclusive = false;
database->KeepConnection = true;
database->ReadOnly = false;}
database->Connected = true;

Nevertheless, I receive an error of this code. It says the user is not associated with trusted connection.

Any help? Any Idea?.

edalorzo@hotmail.com
 
Forget about it. I myself found the answer

Code:
        TDatabase *sqlServerDatabase = new TDatabase(NULL);
        try{
                sqlServerDatabase->AliasName="Security";
                sqlServerDatabase->DatabaseName = "Security";
                sqlServerDatabase->LoginPrompt=false;

                /*Parametros de la conexión*/
                sqlServerDatabase->Params->Add("Driver={SQL Server}");
                sqlServerDatabase->Params->Add("SERVER=Madrid");
                sqlServerDatabase->Params->Add("UID=LordOfCode");
                sqlServerDatabase->Params->Add("PWD=codemaster");
                sqlServerDatabase->Params->Add("DATABASE=Security");

                sqlServerDatabase->Connected = true;
        }catch(Exception& e){
                printf(e.Message.c_str());
        }
        if (sqlServerDatabase->Connected){
                sqlServerDatabase->Close();
        }

edalorzo@hotmail.com
 
Hi,

Good to know that you know how to connect to database through c++. I want to know how to connect to database which is on another server through my workstation. I only have rights to access the database on that server and don't have rights to access the whole server. This thing has to be done in c++ as we have code ready which gets data from somewhere and massages that data and outputs in a text file with delimeter as "|". Can somebody please help me?

So the scenerio is simple, want to connect from a workstation to my testing server and which has connection to the SQL Server where the database resides.
 
What components are you using? I use the ADO data set and a data link dialog box. See faq101-5282.

James P. Cottingham

There's no place like 127.0.0.1.
There's no place like 127.0.0.1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top