fguihen Posted May 28, 2004 Posted May 28, 2004 my database is in the same folder as my asp page, so i use the mapPath function to try to connect to it using the line: conn1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".")+ "/db4.mdb"); i then have the the two lines following it: sql = new System.Data.OleDb.OleDbCommand ("select username,password from users"); this.conn1.Open(); this.dataReader = new OleDbDataReader(); dataReader = sql.ExecuteReader(); it all seems correct to me but i keep getting this error, which i can make no sense of: System.InvalidOperationException: ExecuteReader: Connection property has not been initialized. at System.Data.OleDb.OleDbCommand.ValidateConnectionAndTransaction(String method, Int32& localState) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at Upload.Logon.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\upload\logon.aspx.cs:line 72 any ideas at all.its been wrecking my head for two hours now. Quote
Moderators Robby Posted May 28, 2004 Moderators Posted May 28, 2004 Trace this, what do you get? Server.MapPath(".")+ "/db4.mdb" Quote Visit...Bassic Software
wessamzeidan Posted May 28, 2004 Posted May 28, 2004 first of all I never knew you can initialize a datareader second, you need to give the connection object to the command object sql.connection=conn1 Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
fguihen Posted May 28, 2004 Author Posted May 28, 2004 from what i understand, that should bring me to the db4 file in the folder fin which the asp page is in on the server. im prob wrong though as i really dont understand mappath() . il mess with that. thanks Quote
Moderators Robby Posted May 28, 2004 Moderators Posted May 28, 2004 You probable wanted something like this... Server.MapPath("db4.mdb") Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.