Insertion in table
-
I am using SQL Server EXPRESS Edition for my C# client. I have written an SP
InsertData
for inserting data into a table. Another SPGETDATA
fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I callInsertData
SP and then in the same event handler I callGETDATA
SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
Have you tried to run
InserData
via query analyzer ? Put break points and step into the code.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
Have you tried to run
InserData
via query analyzer ? Put break points and step into the code.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
Yes I have tried the procedure in query analyser and it inserts data successfully. I have added 4 records in tabale using this SP but and everytime I start application, it starts from ID = 5 (ID is IDENTITY column).
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
I am using SQL Server EXPRESS Edition for my C# client. I have written an SP
InsertData
for inserting data into a table. Another SPGETDATA
fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I callInsertData
SP and then in the same event handler I callGETDATA
SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
Just a lil doubt, are you explicitly opening transactions? If yes, you'll have to commit your transactions by using the COMMIT keyword everytime you insert a row. By default AUTO COMMIT is ON in SQL Server. Check your connection properties to see if its turned off somewhere.
SG Cause is effect concealed. Effect is cause revealed.
modified on Monday, March 24, 2008 5:39 AM
-
Just a lil doubt, are you explicitly opening transactions? If yes, you'll have to commit your transactions by using the COMMIT keyword everytime you insert a row. By default AUTO COMMIT is ON in SQL Server. Check your connection properties to see if its turned off somewhere.
SG Cause is effect concealed. Effect is cause revealed.
modified on Monday, March 24, 2008 5:39 AM
No I am not using this statment and I have also checked
SqlCommand
object's propertys using it like thiscom.Transaction.Commit();
function but it is not working. :( I think it is the problem of SQLEXPRESS that may does not allow inserting or updating by default. If anyone give any idea about it, I shall be thankful.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
I am using SQL Server EXPRESS Edition for my C# client. I have written an SP
InsertData
for inserting data into a table. Another SPGETDATA
fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I callInsertData
SP and then in the same event handler I callGETDATA
SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Check your connection string/properties. Are you connecting to SQL Express as 'User Instance = True' ?
I don't speak Idiot - please talk slowly and clearly
Yes this property is set to true as 'User Instance = True'. I think it might be some limitation of SQL EXpress but uptil now I haven't come to know about any such limitation. Same problem also posted here by someone. http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2555908&SiteID=17[^]
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Yes this property is set to true as 'User Instance = True'. I think it might be some limitation of SQL EXpress but uptil now I haven't come to know about any such limitation. Same problem also posted here by someone. http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2555908&SiteID=17[^]
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Make sure your connections string says something like: Database='Path&FileName';...;User Instance = False
I don't speak Idiot - please talk slowly and clearly
Well everything is fine with connection string and application works fine enough as far as it is in RAM but acutal changes are not commited.
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
I am using SQL Server EXPRESS Edition for my C# client. I have written an SP
InsertData
for inserting data into a table. Another SPGETDATA
fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I callInsertData
SP and then in the same event handler I callGETDATA
SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
Oh dear. This old chestnut again. I assume that you are running SQL Server Express as part of your application and that you have a local database. Here's a hint - when the application runs, the database is copied into the bin directory (everytime it's run from the Visual Studio menu). This means that the work you've inserted effectively disappears because it has been replaced by a new copy of the database. In order to see the data, you need to look in the Debug (or Release depending on your build mechanism) directory where you will be able to see the database. You can open it up and take a look at it in there.
Deja View - the feeling that you've seen this post before.
-
Oh dear. This old chestnut again. I assume that you are running SQL Server Express as part of your application and that you have a local database. Here's a hint - when the application runs, the database is copied into the bin directory (everytime it's run from the Visual Studio menu). This means that the work you've inserted effectively disappears because it has been replaced by a new copy of the database. In order to see the data, you need to look in the Debug (or Release depending on your build mechanism) directory where you will be able to see the database. You can open it up and take a look at it in there.
Deja View - the feeling that you've seen this post before.
Thank u very mcuh Henlon. That was AWESOME. [:)] That really works. When I opened the database from bin folder it contained all the data that was inserted earlier. I don't know how should I say thank u to u. Thank u so much. [;)]
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Thank u very mcuh Henlon. That was AWESOME. [:)] That really works. When I opened the database from bin folder it contained all the data that was inserted earlier. I don't know how should I say thank u to u. Thank u so much. [;)]
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
No problem. I'm glad I could help.
Deja View - the feeling that you've seen this post before.