Friday, February 10, 2012

Connect to SQL Enterprise 2000

Hi,
I am new to SQL Server can someone please tell me how to connect to SQL
Server Remotely Using VB6 or MS Access 2003.
Using code?
I have this code that I am using to connect Locally
Cn.Provider = "sqloledb"
Cn.Properties("Prompt") = adPromptNever
Cn.Properties("Data Source").Value = "Dell"
Cn.Properties("Initial Catalog").Value = "Namedb"
Cn.Properties("User ID").Value = txtUserName.Text
Cn.Properties("Password").Value = txtPassword.Text
what do I need to add to this to make it work.
Thanks
DibYou just need to change the "Data Source" property. BTW, to generate the com
plete connection string, you can use a udl file. Create a text document and
call it xxx.udl. Double click the udl file and a wizard will have tabs for e
ach part. Finally open the
udl file in notepad to see the connection string. This is available from MDA
C 2.5 onwards I believe.
HTH,
Paul Ibison|||Thanks for your reply,
Do I need to write any thing in the document of the file I am creating?
Because I copied the string into notepad and saved it as .udl and I am
getting an error saying that it File cannot open ensure that this is a valid
Datalink file
this is what I have in the file
Cn.Provider = "sqloledb"
Cn.Properties("Prompt") = adPromptNever
Cn.Properties("BTW").Value = "Dell"
Cn.Properties("Initial Catalog").Value = "database"
Cn.Properties("User ID").Value = "name"
Cn.Properties("Password").Value = "password"
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:30042251-4FA5-4F91-B418-025926016417@.microsoft.com...
> You just need to change the "Data Source" property. BTW, to generate the
complete connection string, you can use a udl file. Create a text document
and call it xxx.udl. Double click the udl file and a wizard will have tabs
for each part. Finally open the udl file in notepad to see the connection
string. This is available from MDAC 2.5 onwards I believe.
> HTH,
> Paul Ibison|||Dib,
the syntax would change a bit, as you don't need to use the properties
collection, but can put it all together:
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=name;Password=password;Initial Catalog=database;Data Source=Dell"
To get the udl file to open, create a blank textfile named as xxx.udl. Then
double click it to go through the wizard. Inside the udl file (if you open
using notepad) will be the connection string in the format above, or
different for a remote server.
HTH,
Paul Ibison|||Paul,
Thanks a lot for taking the time to answer my question, I got it to work for
now.
Thanks
Again
Dib
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:O38bcfIKEHA.4004@.TK2MSFTNGP11.phx.gbl...
> Dib,
> the syntax would change a bit, as you don't need to use the properties
> collection, but can put it all together:
> cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security
Info=False;User
> ID=name;Password=password;Initial Catalog=database;Data Source=Dell"
> To get the udl file to open, create a blank textfile named as xxx.udl.
Then
> double click it to go through the wizard. Inside the udl file (if you open
> using notepad) will be the connection string in the format above, or
> different for a remote server.
> HTH,
> Paul Ibison
>

No comments:

Post a Comment