Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have a winforms application I'm building in VS 2010. Originally its database was hosted in SQL express but on publishing the app I discovered it threw an "sql-instance not found" error.

I assumed this was because there was no local copy of the dB stored in the project. I then located the instance of the db stored in SQL express made a copy of the .mdf file and added it as a data source to the project while creating an accompanying data set.

I then updated all references in the project to point to the new dataset and compiled error free. However I discovered now that when I attempt to create new records they are accessible from within the application for a limited time but when I close and access the dB from the back end I can only see entries which were created before the database was exported and the .mdf file was added to the project.

I'm further confounded by the fact that I can close the application and request for the most recent records using the datase and the recent entries get retrieved, even after I stop debugging, shut down VS and bring it back up the entries remain visible for a while before eventually becoming invisible again.

Furthermore I assign ado.net's update method to an integer called rowsAffected which has to return 1 for the application to move forward. It does return the value so I'm a bit confused.

I'm at my wit's end anyone have any idea what the problem might be?
Posted
Comments
[no name] 1-Oct-14 5:47am    
"what the problem might be" , well... it sounds an awful lot like you do not understand what SQL Server is or how it works. Data does not just appear and vanish and "sql-instance not found" means just like it says, you published your application to a computer that did not have SQL Server installed on it or you did not change your connection string to point to a valid server.
Sinisa Hajnal 1-Oct-14 7:07am    
And your data "vanishing" and "appearing" means you're accessing two different databases, one within the project and one on SQLExpress instance on your developer machine (that is, the original MDF).
zillaitor 2-Oct-14 16:00pm    
I admit that I am still learning the rudiments of SQL.

I reverted to using my SQL express server and updated the connection string like you mentioned and data gets persisted as requested now, thanks.

I'd like the final application to have one db hosted on Windows server 2008 with the application installed on client machines within the same local network.

Do you have any suggestions as to how this can be done?

Thomas Nielsen - getCore 1-Oct-14 8:45am    
You should not think that your sql server is something that should deploy with your project as such it should always be there and your project should connect to it.
My best bet is that your architecture is wrong because your mdf file should not be part of your project or deploy with it because that would put it on each of the clients and their updates would of cause disappear to each other unless you have a very clever and completely unnecessary replication- and distributed database setup.
zillaitor 2-Oct-14 16:03pm    
Thanks Thomas, I've reverted to using SQL Express as my server and updated the connection string.

It works just fine now.

I was always of the impression that applications were published with instances on their dbs as part of the project. Thanks for clearing that up for me.

I'd like the final application to have one db hosted on Windows server 2008 with the application installed on client machines within the same local network.

Do you have any suggestions as to how this can be done?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900