Hi all

I have this program i writing using C# 2003 and ASP.net, When i try to connect to the database it gives the error below. I do not know what is wrong, please help.

[
Server Error in '/BookFlight' Application.

The Microsoft Jet database engine cannot open the file 'C:\Documents and Settings\sibotho\My Documents\Visual Studio Projects\BookFlight\BookingFlights.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file 'C:\Documents and Settings\sibotho\My Documents\Visual Studio Projects\BookFlight\BookingFlights.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

Source Error:

Line 183: private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)Line 184: {Line 185: oleDbConnection1.Open();Line 186:Line 187: oleDbDataAdapter1.SelectCommand.CommandText =
Source File: c:\inetpub\wwwroot\bookflight\login.aspx.cs Line: 185

Stack Trace:

[OleDbException (0x80004005): The Microsoft Jet database engine cannot open the file 'C:\Documents and Settings\sibotho\My Documents\Visual Studio Projects\BookFlight\BookingFlights.mdb'. It is already opened exclusively by another user, or you need permission to view its data.] System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) System.Data.OleDb.OleDbConnection.InitializeProvider() System.Data.OleDb.OleDbConnection.Open() BookFlight.WebForm1.CustomValidator1_ServerValidate(Object source, ServerValidateEventArgs args) in c:\inetpub\wwwroot\bookflight\login.aspx.cs:185 System.Web.UI.WebControls.CustomValidator.OnServerValidate(String value) System.Web.UI.WebControls.CustomValidator.EvaluateIsValid() System.Web.UI.WebControls.BaseValidator.Validate() System.Web.UI.Page.Validate() System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
]

What am I Missing.

Recommended Answers

All 8 Replies

hi sibotho,

there could be two problems
When you are running your program please do not open the database keep it closed.
If this does not help check your program and see if you have already opened your connection for any other operation close that application. Let me know if this helps

Kind Regards,

Maggi

hi sibotho,

there could be two problems
When you are running your program please do not open the database keep it closed.
If this does not help check your program and see if you have already opened your connection for any other operation close that application. Let me know if this helps

Kind Regards,

Maggi

Hi

Thanks for your help,

I run my program with the database closed and i have not opened the connection for any other operation. but now it gives me a different error:

[System.Data.OleDb.OleDbException: No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D). at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at BookFlight.RegistrationForm.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\bookflight\registrationform.aspx.cs:line 113]

Do you know what could be causing this specific error?

Thanks again
sibotho

Hi,
Can you give me code for the database connection and query you are trying to perform for the database.

I am trying to insert something in my database using the following code.

[
try
{
string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+
";User Id=Admin;Password=;";

oleDbConnection1 = new System.Data.OleDb.OleDbConnection(ConnString);


this.oleDbConnection1.Open();

//while (dataReader.Read())
string strInsert;

strInsert = "insert into users(userName, password, emailAdd, cellNo)"
+ " values('" + this.usenameTextBox.Text + "', '"
+ this.passwordTextBox.Text + "', '"
+ this.emailTextBox.Text + "', '"
+ this.phoneTextBox.Text + "')";

if (this.usenameTextBox.Text !="" && this.passwordTextBox.Text !=""&& this.emailTextBox.Text !="" && this.phoneTextBox.Text !="")
{
this.oleDbDataAdapter1.InsertCommand.CommandText = strInsert;
//do the insert
this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
}
}
catch(System.Data.OleDb.OleDbException ex)
{
erroLabel.Visible = true;
erroLabel.Text += ex.ToString();
]

hi ,

try this way

try
    {
        this.oleDbDataAdapter1.InsertCommand.CommandText = 
            "INSERT INTO BookDb (author, EditionNumber, ISBN, Title)" +
            "VALUES     ('"+ this.author_textBox.Text        
            +"','"+this.ed_textBox.Text+
            "' , "+ this.isbn_textBox.Text +",'"+   
            this.title_textBox.Text+"')";
        //open the bridge between the application and the datasource
        this.oleDbConnection1.Open();
        this.oleDbDataAdapter1.InsertCommand.Connection =  oleDbConnection1;
        //execute the qurey 
        this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
        //close the connection
        this.oleDbConnection1.Close();
        MessageBox.Show("Record insedted Successfully");  //inform the user
        //clear the form 
        this.title_textBox.Text = "";
        this.isbn_textBox.Text = "";
        this.author_textBox.Text = "";
        this.ed_textBox.Text = "";
        //show the qurey
        this.qurey_label.Text = "";
        this.qurey_label.Text =                                    
        oleDbDataAdapter1.InsertCommand.CommandText.ToString();
    }
    catch(System.Data.OleDb.OleDbException exp)
    {
        //close the connection
        this.oleDbConnection1.Close();
        MessageBox.Show(exp.ToString());
    }

make appropriate changes in this code according to your needs see if it works and let me know

Did you set appropriate permissions on your database file? ASP.net user need read/write permissions.

Thanks a lot maggik your code worked. I am relly greatfull

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.