 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
surena Guest
|
Posted: Sun Apr 08, 2007 1:19 am Post subject: connecting to SQL server 2000 |
|
|
Hi,
I have installed SQL server 2000 on my windows xp. I want to use a
table of one of my databases in a delphi 7 application. I use windows
authentication to connect to SQL server. How I can write an aplication
in delphi to connect to SQL server. Delphi always prompted me for user
name and password and I do not know what to do.
In visual basic I wrote a code like:
Dim cn As New ADODB.Connection
Dim ServerName As String, cmdname As String
Dim DatabaseName As String
Dim rs As ADODB.Recordset
ServerName = "(local)"
DatabaseName = "mypatient"
cn.ConnectionTimeout = 150
cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open
But I do not know what to do in delphi. Any help?
Surena. |
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Sun Apr 08, 2007 2:45 am Post subject: Re: connecting to SQL server 2000 |
|
|
surena wrote:
| Quote: |
I have installed SQL server 2000 on my windows xp. I want to use a
table of one of my databases in a delphi 7 application. I use windows
authentication to connect to SQL server. How I can write an aplication
in delphi to connect to SQL server. Delphi always prompted me for user
name and password and I do not know what to do.
In visual basic I wrote a code like:
ServerName = "(local)"
DatabaseName = "mypatient"
cn.ConnectionTimeout = 150
cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open
But I do not know what to do in delphi. Any help?
|
Use the ADO components. Drop an ADOConnection component down and in the
Object Inspector click the ConnectionString property, then click the elipsis
button there. On the next dialog select "Use Connection String" and click
the Build button. Select the SQL Server OLE DB driver, and follow through
from there.
You can do this in code too if you know the required details, e.g:
ADOConnection1.ConnectionString :=
'Provider=SQLOLEDB.1;Integrated Security=SSPI;'
+ 'Persist Security Info=False;'
+ 'Initial Catalog=Northwind;Data Source=(local)';
--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"At the apex of every great tragedy of mankind there stands the figure
of an incorruptible altruist." - Ayn Rand |
|
| Back to top |
|
 |
Alain Quesnel Guest
|
Posted: Mon Apr 09, 2007 5:10 am Post subject: Re: connecting to SQL server 2000 |
|
|
You also need to set the TADOConnection.LoginPrompt property to False.
--
Alain Quesnel
alainsansspam (AT) logiquel (DOT) com
www.logiquel.com
"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote in message
news:461810e8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | surena wrote:
I have installed SQL server 2000 on my windows xp. I want to use a
table of one of my databases in a delphi 7 application. I use windows
authentication to connect to SQL server. How I can write an aplication
in delphi to connect to SQL server. Delphi always prompted me for user
name and password and I do not know what to do.
In visual basic I wrote a code like:
ServerName = "(local)"
DatabaseName = "mypatient"
cn.ConnectionTimeout = 150
cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open
But I do not know what to do in delphi. Any help?
Use the ADO components. Drop an ADOConnection component down and in the
Object Inspector click the ConnectionString property, then click the
elipsis button there. On the next dialog select "Use Connection String"
and click the Build button. Select the SQL Server OLE DB driver, and
follow through from there.
You can do this in code too if you know the required details, e.g:
ADOConnection1.ConnectionString :=
'Provider=SQLOLEDB.1;Integrated Security=SSPI;'
+ 'Persist Security Info=False;'
+ 'Initial Catalog=Northwind;Data Source=(local)';
--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"At the apex of every great tragedy of mankind there stands the figure
of an incorruptible altruist." - Ayn Rand
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|