can't connect to my DB...

G

gloria

So I created a MS DL that I know works. I can test the connection.
Provider=SQLOLEDB;Password=xxx;Persist Security Info=True;User
ID=xxx;Initial Catalog=olite3i;Data Source=niktraining

However, when I try to use this string in my code, I don't even get the
error in my catch. What am I doing wrong? If I use
SqlClient/SqlConnection, I at least can get the catch to work and the
error: "Keyword not supported: 'provider'." But I know my connect
string works because I can test it.

What am I doing wrong?

Thanks!

--gloria

---------------
using System;
using System.Data;
using System.Data.OleDb;
....
string connStr = "Provider=SQLOLEDB;Password=xxxx;Persist Security
Info=True;User ID=xxx;Initial Catalog=olite3i;Data Source=niktraining";
Console.WriteLine("connStr: " + connStr);

try
{
OleDbConnection cn = new OleDbConnection();
cn.ConnectionString = connStr;
cn.Open();
} catch (Exception ex) {
Console.WriteLine("Attepmet to connect failed.\n" + ex.Message);
}
 
E

Elton Wang

Hi Gloria,

For SqlClient.SqlConnection, the connection string is like

Password=xxx;Persist Security Info=True;User
ID=xxx;Initial Catalog=olite3i;Data Source=niktraining

No Provider.

HTH,

Elton Wang
(e-mail address removed)
 
G

gloria

Figured out my issue. I was running the app from a networked drive and
didn't have the permissions set up to do this. I copied my info to a
local disk and it worked like a charm. Spent a day and a half trying
to figure out what I was doing wrong. The fun mistakes in learning a
new technology. :)

Thanks!
 

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