Database Connection problem in sql server 2005
-
Hi to all I have a problem with database in vb.net using sqlexpress. My problem is: I have created a .mdf database file and tables in it, and written code for inserting data to this table through command object. But my real prob is when i supply the connection string which is created by the "data configuration wizard" to this cmd object then on runtime insert executes and also data is visible in datagridview but when i check the data in the table it is not there and all fields are NULL. given connection string. ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\LIB.mdf;Integrated Security=True;User Instance=True") But on the otherhand if i give connection string as :: "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\LIB\LIB\LIB.mdf;Integrated Security=True;User Instance=True" then data is successfully inserted in the database and i m also able to view it in my database table. So if Any one can help me it will be highly appreciable. Thanks.
-
Hi to all I have a problem with database in vb.net using sqlexpress. My problem is: I have created a .mdf database file and tables in it, and written code for inserting data to this table through command object. But my real prob is when i supply the connection string which is created by the "data configuration wizard" to this cmd object then on runtime insert executes and also data is visible in datagridview but when i check the data in the table it is not there and all fields are NULL. given connection string. ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\LIB.mdf;Integrated Security=True;User Instance=True") But on the otherhand if i give connection string as :: "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\LIB\LIB\LIB.mdf;Integrated Security=True;User Instance=True" then data is successfully inserted in the database and i m also able to view it in my database table. So if Any one can help me it will be highly appreciable. Thanks.
Is'nt this a problem of relative Vs global paths ? I give you an example I know: if you call GetCurrentDir within a code that you execute through Debug-->Start Without Debugging command then you'll have something different as when you go to the Debug directory of your executable and run it from there. Thus this may lead to different behaviours as when we have relative entries, such that things will work fine, in one case, and fail in the other. Ahmed. Tunisia.