im a newbie at C# and Database's. I need your help. I use Visual Studio C# Gui and SQL Server Managment Studio from Microsoft.
My problem: I have a Database at SQL Server Managment. Im only able to view it when im connectet about Datagridview in Visual Studio C#. (y thats pretty normal). Now, i want to copy the Database file (.mdf and .ldf) and use it, when im not connectet to view it. Only to view.
SqlCeConnection myConnection2 = new SqlCeConnection(@"Data Source=C:\Users\XX\Desktop\XX\Database.mdf");
SqlCeDataAdapter sda = new SqlCeDataAdapter("Select* FROM Database", myConnection2);
DataTable dt = new DataTable();
myConnection2.Open();
sda.Fill(dt);
dgv_Test.DataSource = dt;
This is not working!
How can i do it?
Sorry I don't know how to use your SQL without a connection but you could just make a mock repository and put fake data into that. Then you can just call that repo to have a fake database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.