Skip to Content.
Sympa Menu

freetds - [freetds] Res: How to make a connection without freetds.conf

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Alexandre Gazola <alexandregazola AT yahoo.com.br>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Res: How to make a connection without freetds.conf
  • Date: Mon, 16 Jul 2007 14:15:04 -0700 (PDT)

Hello,

I I´m not using SQLDriverConnect to make my connection....

I´m doing the connection with FreeTDS using the function ct_connect (see the
simple code bellow).

The "host" parameter used to make the connection matches a section in the
freetds.conf file, as specified. Is there how to modify the code bellow so
that the freetds.conf file is not needed?

thank you

bool
TeFreeTDS::connect (const string& host, const string& user, const string&
password, const string& database, int port)
{
CS_RETCODE ret;
char query[30];

errorMessage_ = "";

close();

ret = ct_con_alloc(ctx_, &conn_);
if (ret != CS_SUCCEED)
{
errorMessage_ = "Connect Alloc failed!";
return false;
}

ret = ct_con_props(conn_, CS_SET, CS_USERNAME, (char *) user.c_str(),
CS_NULLTERM, NULL);
if (ret != CS_SUCCEED)
{
errorMessage_ = "ct_con_props() SET USERNAME failed!";
return false;
}

ret = ct_con_props(conn_, CS_SET, CS_PASSWORD, (char *) password.c_str(),
CS_NULLTERM, NULL);
if (ret != CS_SUCCEED)
{
errorMessage_ = "ct_con_props() SET PASSWORD failed!";
return false;
}

ret = ct_connect(conn_, (char *) host.c_str(), CS_NULLTERM);
if (ret != CS_SUCCEED)
{
errorMessage_ = "Connection failed!";
return false;
}

strcpy(query, "use ");
strncat(query, (char *) database.c_str(), 20);

if (!execute(query))
return false;

isConnected_ = true;

host_ = host;
user_ = user;
password_ = password;
database_ = database;

return true;
}


----- Mensagem original ----
De: James K. Lowden <jklowden AT freetds.org>
Para: FreeTDS Development Group <freetds AT lists.ibiblio.org>
Enviadas: Sexta-feira, 13 de Julho de 2007 17:08:52
Assunto: Re: [freetds] How to make a connection without freetds.conf

Alexandre Gazola wrote:
> I checked the DNS-less section of the user guide on the site, and
> changed my connection string to the following:
>
> "DRIVER=FreeTDS;SERVER=forte;UID=teste;PWD=teste;DATABASE=GAZOLA_UNBA_R
> ;TDS_Version=7.0;Port=1695;"
>
> but that DIDN'T WORK.


1. Make sure you're using SQLDriverConnect.
2. Try export TDSDUMP=stdout and see if it's connecting to your host
correctly. The log will show your server hostname and port (and probably
the TDS version). If those are right, it's an authentication issue.

--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds







Flickr agora em português. Você cria, todo mundo vê.
http://www.flickr.com.br/




Archive powered by MHonArc 2.6.24.

Top of Page