how to get database list?

L

Lloyd Dupont

I have some connection problem and wonder if I do everything correctly.

I'm trying:
I created a SqlConnection with the ConnectionString:
Address=myIp,myPort;User ID=sa;Pwd=password

and with this connection i "PLAN" to run sp_databases stored procedures.
However when I open the connection I get:
SqlException: SQL Server does not exist or access denied.

Although I checked
myDatabase->property->security->Autentication (which is mixed mode SQL
Server & Windows)
and I also check the user sa (who is admin) and its passwrod.

Any idea what I've done wrong ?

Cheers mates!
Lloyd
 
M

Miha Markic [MVP C#]

Hi Lloyd,

To create a correct connection string (if this is a problem), go to server
explorer window within vs.net, add a database server entry and drag&drop it
on the form - it will create a connection with correct string for you (you
might copy it where you need it).
 
L

Lloyd Dupont

Hi Miha!

While it's a good idea, it doesn't work.
The server explorer let me only drag table whereas I would like to drag just
the server!

My purpose it to have a DB wizard to connect to the server.
It as IP/port user & pwd of the db, then there is a button to choose the
database and a button to choose the tables....

I have problem with the database finder button....
Any tip on how to implement it?

I will revert to my previous code (Database=; ...) but it will be nice tyo
know how to do that cleanly...

Miha Markic said:
Hi Lloyd,

To create a correct connection string (if this is a problem), go to server
explorer window within vs.net, add a database server entry and drag&drop
it on the form - it will create a connection with correct string for you
(you might copy it where you need it).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Lloyd Dupont said:
I have some connection problem and wonder if I do everything correctly.

I'm trying:
I created a SqlConnection with the ConnectionString:
Address=myIp,myPort;User ID=sa;Pwd=password

and with this connection i "PLAN" to run sp_databases stored procedures.
However when I open the connection I get:
SqlException: SQL Server does not exist or access denied.

Although I checked
myDatabase->property->security->Autentication (which is mixed mode SQL
Server & Windows)
and I also check the user sa (who is admin) and its passwrod.

Any idea what I've done wrong ?

Cheers mates!
Lloyd
 
M

Miha Markic [MVP C#]

Lloyd,

Check out sp_databases stored procedure, or or
OleDbConnection.GetOleDbSchemaTable table.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Lloyd Dupont said:
Hi Miha!

While it's a good idea, it doesn't work.
The server explorer let me only drag table whereas I would like to drag
just the server!

My purpose it to have a DB wizard to connect to the server.
It as IP/port user & pwd of the db, then there is a button to choose the
database and a button to choose the tables....

I have problem with the database finder button....
Any tip on how to implement it?

I will revert to my previous code (Database=; ...) but it will be nice tyo
know how to do that cleanly...

Miha Markic said:
Hi Lloyd,

To create a correct connection string (if this is a problem), go to
server explorer window within vs.net, add a database server entry and
drag&drop it on the form - it will create a connection with correct
string for you (you might copy it where you need it).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Lloyd Dupont said:
I have some connection problem and wonder if I do everything correctly.

I'm trying:
I created a SqlConnection with the ConnectionString:
Address=myIp,myPort;User ID=sa;Pwd=password

and with this connection i "PLAN" to run sp_databases stored procedures.
However when I open the connection I get:
SqlException: SQL Server does not exist or access denied.

Although I checked
myDatabase->property->security->Autentication (which is mixed mode SQL
Server & Windows)
and I also check the user sa (who is admin) and its passwrod.

Any idea what I've done wrong ?

Cheers mates!
Lloyd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top