new sqlconnection problem

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I want to use a table store the database connection. (e.g myDBC)

I use cmdReader to get the string from that table sucesfully and then want
to create it .
Dim strConnection as string = myReader.item(conn)
Dim cnSqlServer as new SqlConnection(strConnection)

I check that I can get the strConnection very well. (e.g "server=MyServer;
database=Account;user id =sa;password=;")
However, as newSqlConnection(strConnection) it got errors.

Does anyone try this similar approach ?? Thanks a lot
 
Hi,

What's your error? And have you got option strict on turned on, so you can
check it's not a converting error

Greetz Peter
 
As i run the form ,unknow command "user id"

Peter Proost said:
Hi,

What's your error? And have you got option strict on turned on, so you can
check it's not a converting error

Greetz Peter
 
Hi,

I would try this:

Dim strConnection as string = cstr(myReader.item(conn))

Then set a breakpoint at the next line, and make sure the Connection string
is correct:
breakpoint at: Dim cnSqlServer as new SqlConnection(strConnection)
Connection string should look like this:
"Data Source=\\Servername;Initial Catalog=DatabaseName;User
Id=something;Password=something;"

Btw when can you connect to the server if you type the connection string in
the program and don't get it from the reader?

Greetz Peter
 

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

Back
Top