用VS写的窗体程序,把简历的数据库全部放在Debug文件夹下,然后压缩打包后,在自己电脑上能正常运行,但是在别人电脑上运行不了,是什么原因?
运行时,提示的错误:
连接数据库的代码
public void DataSetShow()
{
DataSet ds = new DataSet();
string path= System.AppDomain.CurrentDomain.BaseDirectory;
path.Replace("\\", @"\");
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="+path+"Earth.mdf;Integrated Security=True";
conn.Open();
using (SqlCommand command = conn.CreateCommand())
{
command.CommandText = "select * from" + " " + comboBox1.Text;
SqlDataAdapter da = new SqlDataAdapter(command);
try
{
da.Fill(ds);
}
catch
{
}
}
}
DataTable dt = new DataTable();
dt = ds.Tables[0].Copy();
this.dataGridView1.DataSource = dt; //绑定到datagridview中显示
}