2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by shivya
0

For connecting to a database you need several things. A connection string holds the information relevant to connecting to the database (location, login details, security, etc), a connection object which you open and close to connect to the database and a command object which takes the SQL query and actions it on the database inserting or returning data as appropriate.
There is a very useful site that has all the connection strings you will ever need. I can't remember the name but type 'connection strings' into google and you'll find it.

A basic database section of code might look like this in C#

string connectionStr = // your connection string goes here;
String SQL = "select * from some_table";
oleDbConnection conn = new oleDbConnection(connectionStr);
oleDbCommand cmd = new oleDbCommand(sql, conn);
dataTable dt = cmd.executeScalar();

you can obviously return a range of data types: strings, ints, row sets or entire tables. What you are returning will determine what object you use to catch and handle the returned data.
Thats a basic start anyway. Hope it helps.

0

For connecting to a database you need several things. A connection string holds the information relevant to connecting to the database (location, login details, security, etc), a connection object which you open and close to connect to the database and a command object which takes the SQL query and actions it on the database inserting or returning data as appropriate.
There is a very useful site that has all the connection strings you will ever need. I can't remember the name but type 'connection strings' into google and you'll find it.

A basic database section of code might look like this in C#

string connectionStr = // your connection string goes here;
String SQL = "select * from some_table";
oleDbConnection conn = new oleDbConnection(connectionStr);
oleDbCommand cmd = new oleDbCommand(sql, conn);
dataTable dt = cmd.executeScalar();

you can obviously return a range of data types: strings, ints, row sets or entire tables. What you are returning will determine what object you use to catch and handle the returned data.
Thats a basic start anyway. Hope it helps.

thankyou so much.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.