1

I developed an application. It loads sql database on my pc with this connection string:

Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Database\Books.mdf;Integrated Security=True;User Instance=True

private void Window_Loaded(object sender, RoutedEventArgs e)
    {

        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Database\Books.mdf;Integrated Security=True;User Instance=True");
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = new SqlCommand("SELECT * FROM Lessons", con);
        da.Fill(ds);
        grdPersonnel1.DataContext = ds.Tables[0];
        con.Open();
    }

but, my Database data doesn't load in another pc!

Kia
  • 77
  • 3
  • 14

1 Answers1

0

Do you have SQL server instance Running on that Computer?

Try to Run your Application/Solution on the other P.C on Debug Mode you will see what exactly is the error...make sure you have try and catch in each of your methods/ events.

check this SO post :

Is it possible to run a mdf database without SQL Server program? (c#)

Connecting to sql server database mdf file without installing sql server on client machine?

Regards

Community
  • 1
  • 1
BizApps
  • 6,048
  • 9
  • 40
  • 62