Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why this error is comming when i wploading the file in server

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not use ''; file already in use.
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: Could not use ''; file already in use.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

ASP.NET
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<script  runat="server">
OleDbConnection con;
OleDbCommand cmd,cmd1;
OleDbDataAdapter da,da1;
DataSet ds,ds1;
void Page_Load(Object s, EventArgs e)
{
Session["s"]=TextBox1.Text;
con=new OleDbConnection();
con.ConnectionString="PROVIDER=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/cvbank.mdb") + "";
con.Open();
ds= new DataSet();
string sql="select * from cv";
da=new OleDbDataAdapter(sql,con);
da.Fill(ds,"cv");
con.Close();
}void go(Object s, EventArgs e)
{string sa=TextBox1.Text.Trim();
string pw=TextBox2.Text.Trim();
con.Open();
int r=0,r1=0;
DataRow []rs;
DataRow []rs1;
rs=ds.Tables["cv"].Select("email='"+sa+"'");
r=rs.Length;
rs1=ds.Tables["cv"].Select("pass='"+pw+"'");
r1=rs1.Length;
if(r>0 && r1>0)
{Response.Redirect("account.aspx");
}else
{System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="please enter a valid user id and password";
ph1.Controls.Add(lbl1);
}con.Close();
}void click(Object s, EventArgs e)
{Response.Redirect("cv_posting.aspx");
}
</script>
Posted
Updated 14-Dec-11 22:54pm
v2
Comments
Al Moje 15-Dec-11 4:00am    
What kind of file are you loading? Can you post your code?
Janardan Pandey 15-Dec-11 4:59am    
My code is this fo login given below. but when i press go button then this error is comming.

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not use ''; file already in use.
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: Could not use ''; file already in use.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


code here

<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<script runat="server">
OleDbConnection con;
OleDbCommand cmd,cmd1;
OleDbDataAdapter da,da1;
DataSet ds,ds1;
void Page_Load(Object s, EventArgs e)
{
Session["s"]=TextBox1.Text;
con=new OleDbConnection();
con.ConnectionString="PROVIDER=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/cvbank.mdb") + "";
con.Open();
ds= new DataSet();
string sql="select * from cv";
da=new OleDbDataAdapter(sql,con);
da.Fill(ds,"cv");
con.Close();
}void go(Object s, EventArgs e)
{string sa=TextBox1.Text.Trim();
string pw=TextBox2.Text.Trim();
con.Open();
int r=0,r1=0;
DataRow []rs;
DataRow []rs1;
rs=ds.Tables["cv"].Select("email='"+sa+"'");
r=rs.Length;
rs1=ds.Tables["cv"].Select("pass='"+pw+"'");
r1=rs1.Length;
if(r>0 && r1>0)
{Response.Redirect("account.aspx");
}else
{System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="please enter a valid user id and password";
ph1.Controls.Add(lbl1);
}con.Close();
}void click(Object s, EventArgs e)
{Response.Redirect("cv_posting.aspx");
}
</script>
Janardan Pandey 15-Dec-11 4:09am    
My code is this

<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<script runat="server">
OleDbConnection con;
OleDbCommand cmd,cmd1;
OleDbDataAdapter da,da1;
DataSet ds,ds1;
void Page_Load(Object s, EventArgs e)
{
Session["s"]=TextBox1.Text;
con=new OleDbConnection();
con.ConnectionString="PROVIDER=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/cvbank.mdb") + "";
con.Open();
ds= new DataSet();
string sql="select * from cv";
da=new OleDbDataAdapter(sql,con);
da.Fill(ds,"cv");
con.Close();
}void go(Object s, EventArgs e)
{string sa=TextBox1.Text.Trim();
string pw=TextBox2.Text.Trim();
con.Open();
int r=0,r1=0;
DataRow []rs;
DataRow []rs1;
rs=ds.Tables["cv"].Select("email='"+sa+"'");
r=rs.Length;
rs1=ds.Tables["cv"].Select("pass='"+pw+"'");
r1=rs1.Length;
if(r>0 && r1>0)
{Response.Redirect("account.aspx");
}else
{System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="please enter a valid user id and password";
ph1.Controls.Add(lbl1);
}con.Close();
}void click(Object s, EventArgs e)
{Response.Redirect("cv_posting.aspx");
}
</script>

My code is this fo login given below. but when i press go button then this error is comming.

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not use ''; file already in use.
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: Could not use ''; file already in use.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


code here

<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<%@ Page Language="C#" Debug="true" %>
<script   runat="server">
OleDbConnection con;
OleDbCommand cmd,cmd1;
OleDbDataAdapter da,da1;
DataSet ds,ds1;
void Page_Load(Object s, EventArgs e)
{
Session["s"]=TextBox1.Text;
con=new OleDbConnection();
con.ConnectionString="PROVIDER=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/cvbank.mdb") + "";
con.Open();
ds= new DataSet();
string sql="select * from cv";
da=new OleDbDataAdapter(sql,con);
da.Fill(ds,"cv");
con.Close();
}void go(Object s, EventArgs e)
{string sa=TextBox1.Text.Trim();
string pw=TextBox2.Text.Trim();
con.Open();
int r=0,r1=0;
DataRow []rs;
DataRow []rs1;
rs=ds.Tables["cv"].Select("email='"+sa+"'");
r=rs.Length;
rs1=ds.Tables["cv"].Select("pass='"+pw+"'");
r1=rs1.Length;
if(r>0 && r1>0)
{Response.Redirect("account.aspx");
}else
{System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="please enter a valid user id and password";
ph1.Controls.Add(lbl1);
}con.Close();
}void click(Object s, EventArgs e)
{Response.Redirect("cv_posting.aspx");
}
</script>
 
Share this answer
 
v2
Hi,

See my sample coding :

C#
 string mdbConnection = "PROVIDER=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/cvbank.mdb") + "";
 DataTable dt = new DataTable();
 OleDbCommand ocmd;
 OleDbDataAdapter oda;
 OleDbConnection oconn = new OleDbConnection(mdbConnection);
 try
 {
     oconn.Open();
     using (oconn)
     {
         StringBuilder sb = new StringBuilder();
         sb.Append("select * from cv");
         using (ocmd = new OleDbCommand(sb.ToString(), oconn))
         {
             ocmd.CommandType = CommandType.Text;
             using (oda = new OleDbDataAdapter(ocmd))
             {
                 oda.Fill(dt);
             }
         }
     }
 }
catch (Exception ex)
{
   // Catch your exeption?...
}



Please do not forget to vote if could help so that other may consider as an answer...

Regards,
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900