Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have created an application in C# with database(.mdb file ).But it is not working when i install it in another system.It showing Database error.
please help me how to solve this problem
Posted
Updated 11-Oct-13 2:23am
v2
Comments
Alexander Dymshyts 11-Oct-13 8:27am    
Do you have a database on another pc?
[no name] 11-Oct-13 8:34am    
It may be cause due to the following reasons,
1. Microsoft Office version(the oledb provider is different for different version).
2. .mdb file path may be not correct.
3. Connection string problem.
Please verify these thing you will get soluton.
Zoltán Zörgő 11-Oct-13 8:34am    
And my car is not starting. What is the problem?
Don't you think you provided a little bit too few information....?
Bernhard Hiller 14-Oct-13 3:10am    
Just stumbled upon:
http://www.codeproject.com/Questions/667864/csharp-application-not-working-in-other-System
Do you have two accounts on CP?

We can't be precise from that little, but the since you mention an MDB file there are a couple of things you should start by checking:
1) Did you install the MDB file when you installed the app?
2) Did you install the file in a location accessible to the new instance of the application?
3) Did you tell the application exactly where the file was?
4) Is the file in a sensible place? Does the App have permission to modify the folder contents?
5) Are you trying to access the same file with more than one user? If so, then expect a world of pain...
 
Share this answer
 
Comments
Member 7698619 15-Oct-13 3:13am    
App.cong file

add name="Marketdb" connectionstring="Data Source=.;AttachDbFilename=~\Market\Data\Bichayath.mdf;Integrated Security=True;User Instance=True" providername="System.Data.SqlClient">


page.cs



private void btnsubmit_Click(object sender, EventArgs e)
{
try
{
SqlCommand insrtcmd = new SqlCommand("insert into bichayathi values(@date,@BillNo,@Fname,@Village,@item,@bags,@Totalbill,@totalexpenditure,@finalamount,@Balance,@humali,@lorryrent,@commision,@bagsrent,@borrow,@dueamount,@intrest)", con);
con.Open();
insrtcmd.Parameters.AddWithValue("@date", System.DateTime.Now);
insrtcmd.Parameters.AddWithValue("@BillNo", txtbillno.Text);
insrtcmd.Parameters.AddWithValue("@Fname", txtname.Text);
insrtcmd.Parameters.AddWithValue("@Village", ddlvlg.Text);
insrtcmd.Parameters.AddWithValue("@item", ddlitem.Text);
insrtcmd.Parameters.AddWithValue("@bags", txtbags.Text);
insrtcmd.Parameters.AddWithValue("@Totalbill", txtbill.Text);
insrtcmd.Parameters.AddWithValue("@totalexpenditure", lblttlexp.Text);
insrtcmd.Parameters.AddWithValue("@finalamount", lblfamt.Text);
insrtcmd.Parameters.AddWithValue("@Balance", txtbal.Text);
insrtcmd.Parameters.AddWithValue("@humali", lblhamali.Text);
insrtcmd.Parameters.AddWithValue("@lorryrent", lbllryrnt.Text);
insrtcmd.Parameters.AddWithValue("@commision", lblcashcut.Text);
insrtcmd.Parameters.AddWithValue("@bagsrent", lblbagrent.Text);
insrtcmd.Parameters.AddWithValue("@borrow", txtbrw.Text);
insrtcmd.Parameters.AddWithValue("@dueamount", txtdueamt.Text);
insrtcmd.Parameters.AddWithValue("@intrest", txtintrate.Text);
insrtcmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record inserted ! ");
// reset();
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace);
}
}

connection string :
SqlConnection con = new SqlConnection(@"Data Source=,;AttachDbFilename=~\Market\Data\Bichayath.mdf;Integrated Security=True;User Instance=True");

and i have attached a .mdb file to the application in data folder.
im getting problem with connection string of .mdb file .
please tell me how to set connection string and also deploy it to any system by making it as exe file
OriginalGriff 15-Oct-13 3:43am    
Well there is your problem!
AttachDbFilename=~\Market\Data\Bichayath.mdf
is a local IIS path to a file, not a path that SQL can recognise - if it even has access to the file on the local PC: remember that the SQL instance may be on a totally different computer. YOu need to use the Server.MapPath method to convert it to a "proper" path specification - do note that you can't do that once, you need to do that each time you attach it as the whole website folder could be moved by your DB admin without you knowing (IIS doesn't care, which is the whole idea)
I would create the DB on the SQL instance, and connect to that instead of attaching an MDB each time, particularly in a web based environment!
Member 7698619 17-Oct-13 1:43am    
Can you please give me a sample application .
OriginalGriff 17-Oct-13 4:16am    
Of what?
once check database connection string.
 
Share this answer
 

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