Connecting to visual Web Dev Database

aderes

New member
Joined
Dec 28, 2005
Messages
3
Hey guys,
Im having some problems connecting to a database made inside of Visual Web Developer 2005 Express Edition. Every time I run the webpage, I get an error (Unrecognized database format C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\WebSites\WebSite2\App_Data\sites.mdf). Its driving me nuts! Any ideas?

Heres a snip of the connection code.

DataTable dt = new DataTable();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbConnection con = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:/Documents and Settings/Owner/My Documents/Visual Studio 2005/WebSites/WebSite2/App_Data/sites.mdf;");
OleDbCommand cmd = new OleDbCommand(sql, con);
da.SelectCommand = cmd;
da.Fill(ds);// errors out here (Unrecognized database format )
dt = ds.Tables[0];

return dt;

Thanks guys!
 
Probably because it isnt an access database, it is probably a SQL Express database. Try using the SQLCLient.Connection to connect instead.
 
Back
Top