So, basically, I am a total n00b. I have never tried connecting a database to a project before.
So, I am using C# for this simulator me and my friends are coding and we want to add a database to it. We have created it using Visual Studio 2010 but we have no idea what to do afterwards. Do we create an extra class to hold all the database stuff and then call its methods from whichever class we want?
The database is a .mdf, in case it's important.
I'm using DAO pattern. Java example: Core J2EE Patterns - Data Access Object.
You can implement it in C#.
DAO or ADO?
Check link.
ok i am doing this whole stuff just for you so please pay attention
here is the psedocode:
1.Check if the connection persists for the database
2.Make the connection using the ,SQL connection Object
3.Use Dataset and DataTable for filling entries
4.Populate the data from the Dataset and DataTable to your desired control
more help will be provided on the request
use LINQ.
create a dbml file in visual studio.
open it and click the Server explorer Link in there. it will open a panel on left side.
Add a new connection to your database.
Drag all the objects/tables to your dbml file
save the file
and you are almost done.
db is connected, now you need to query it
if you need the connection string, its in your web.config already when you save the dbml file.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks