Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to publish a windows form project to an application (.exe) . I used project->properties->publish. there is a database which should published also.

my code is:

OleDbConnection cn = new OleDbConnection("Provider='Microsoft.Jet.OLEDB.4.0';Data Source=|DataDirectory|\\data\\jamiyi.mdb;");
            OleDbDataAdapter adp = new OleDbDataAdapter();
            OleDbCommand cmd = new OleDbCommand();
            DataSet tb = new DataSet();
            try
            {
                cn.Open();
                MessageBox.Show("Connection Open ! ");
                cn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }

the problem is when I run the project the connection to the database opens but when I publish the project the connection fails(I run the published project another PC which has all program requirements).


so what I have to do to fix it?

Thanks in advance.
Posted
Updated 28-Mar-11 10:19am
v2

First of all try to create a setup file this would help you, Now you have to add your .mdb file at same folder where you have added your Primary output.
 
Share this answer
 
Try running as administrator.

And maybe check out the exception.
MessageBox.Show("Can not open connection ! " + ex.Message);
 
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