How to connect to a database through code?

G

Guest

Beginner question:

Can anyone point me in the right direction for learning (url's, books, etc.)
how to connect to an sql or access database through code rather than using
typed datasets? What I am most interested in is sample code that would
connect to say the Northwind database and allow a user to insert, delete,
update data from the tables.

I want the user to first select the location of the database he wants to
connect to, then to load my datagridview with the datasource/ tableadapter
etc.

Thanks for all responses.
Peter
 
C

Cor Ligthert[MVP]

Peter,

In my idea you need a book and then a practical one like Hitchhiker's Guide
to Visual Studio and SQL Server (7th Edition) by
William Vaughn.

For connecting it is only needed:

Dim conn as new DBConnection("connectionString) 'VB
and the little bit more wordy
DBConnection conn = new DBConnection("connectionString'); //C#

Where DB is the provider by instance SqlClient for SQL or OleDB for Jet
(access).

Connectionstring you can find here.

www.connectionstrings.com

Cor
 
M

Miro

I have been going through a book recommended here,

"Programming Microsoft ADO.Net 2.0 Core Reference by David Sceppa"
( its a microsoft book )

and I am very pleased with it so far - gives you and walks you through
plenty of examples of going through code to hit the database.

Miro
 
S

Saimvp

Hi and Hello.
You can use this book titled "c# database 2008 Novice to Prof"
It's all about database programming.

For Connecting in database using code:

//VB
Dim conn as new DBConnection(connectionString)
//C#
DBConnection conn = new DBConnection(connectionString);

Where DB is the provider by instance SqlClient, OleDB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top