Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could someone please provide a reference of how to create a sample database application in WPF 4.5 using Visual Studio 2012. Also, please provide the reference of manipulating the connection string.

My requirement is to load a grid view with data from the table.

Thanks in Advance.
Posted
Comments
[no name] 14-Sep-13 10:03am    
www.google.com and www.connectionstrings.com

 
Share this answer
 
Comments
shanavascruise 14-Sep-13 10:30am    
Dear ProgramFOX,

Thanks for your quick response.
First of all, the tutorial you provided is for Visual Studio 2010.
And, the tutorial begins assuming that I have already created a database and added tables into it.

I also need to know how to do that.
Should I use Local database or Service based databse? why?
Should I use entiry-model or dataset? Why?
Thomas Daniels 14-Sep-13 10:47am    
It should work also for Visual Studio 2012.

Based on your requirements, I think you should use a Local database, because it is used by your application only. More info on the difference between a Local and a Service-based database:
Confused in Local Database and Service-Based Database[^]
http://stackoverflow.com/questions/3447732/which-database-to-use-locally-in-a-desktop-application[^]
http://stackoverflow.com/questions/14558804/confusion-between-service-based-database-and-local-database[^]
http://www.vbforums.com/showthread.php?530655-What-is-the-Different-between-Service-Base-database-and-a-local-database[^]
http://www.dreamincode.net/forums/topic/105448-whats-the-difference-between-local-database-and-service-based-dat/[^]

You should neither use a entity-model, not a dataset. Use a DataTable, as used in your article.
Thomas Daniels 14-Sep-13 11:16am    
And to get the connection string after you created the database, open the Database Explorer, right click on the new database, and click "Properties". The property window will open and then you'll see the "Connection string" property.
shanavascruise 14-Sep-13 12:17pm    
Dear ProgramFOX,

Thanks again for the quick reply.
I copied the connection string as you suggested.
But my connection string only contains DataSource="c:/...../database.sdf".
What about the "Initial Catalog" parameter?

While debugging, I can see that Database is "" and an exception "System.InvalidOperationException" is thrown in ServerVersion. Please help.
Thomas Daniels 14-Sep-13 13:48pm    
You don't need Initial Catalog for a Local database. I've no idea about the error, but you can also try to use a Server-based database and then see whether it gives an error.
Walkthrough: Connecting to Data in a Local Database File (Windows Forms)
http://msdn.microsoft.com/en-us/library/vstudio/ms171890.aspx[^]

Executing SQL Statements that Return Rows Using a Command Object
http://msdn.microsoft.com/en-us/library/vstudio/fksx3b4f.aspx[^]
 
Share this answer
 
v2

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