Your code has:
db = ".\\SQLEXPRESS;";
backslash before SQL Express which is correct but your error says
./sqlexpress;attachdbfilename
- a front slash!
It should be like:
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
Refer:
Connection String for SQL Server[
^]
Make sure that the connection string is correct. Use Visual Studio DEBUGGER and see what is the value of '
cnstr
' being passed to adapter.