hi everyone,
i need help....i want a code that connects to a database and directly opens the database...
thanks in advance.
regards.
A Code that opens access database
Started by elizabethmwashuma, Jun 01 2010 11:20 AM
5 replies to this topic
#1
Posted 01 June 2010 - 11:20 AM
|
|
|
#2
Posted 01 June 2010 - 11:57 AM
at the top you need to have:
then you can use SQL-like method to connect to the database. For an example, let's say you have a windows form with a DataGridView control called "dgvTable" in it:
Of course, there are TONS of ways to do this, and this is a very simple example. But as far as I know, access supports basic SQL syntax.
using System.Data.ODBC;
then you can use SQL-like method to connect to the database. For an example, let's say you have a windows form with a DataGridView control called "dgvTable" in it:
OdbcConnection conn = new OdbcConnection("YOUR CONNECTION STRING GOES HERE. GOOGLE "ACCESS CONNECTION STRING" TO FIND IT");
OdbcQuery query = conn.CreateCommand();
query.CommandText = "select COLUMN1,COLUMN2,COLUMN3 from TABLE1 where COLUMN1 = 'someval'";
Dataset ds = new DataSet();
OdbcDataAdpater adapter = new OdbcDataAdapter(query);
adapter.Fill(ds);
dgvTable.DataSource = ds.Tables[0];
Of course, there are TONS of ways to do this, and this is a very simple example. But as far as I know, access supports basic SQL syntax.
#3
Posted 01 June 2010 - 12:45 PM
what is the main difference btween odbc and oledb.....i tried the code you gave me....has got errors
#4
Posted 01 June 2010 - 01:36 PM
Some searching wouldn't hurt anyone: http://forum.codecal...p-access-c.html
This thread was posted less then a week ago.
This thread was posted less then a week ago.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics
#5
Posted 01 June 2010 - 01:36 PM
Some searching wouldn't hurt anyone: http://forum.codecal...p-access-c.html
This thread was posted less then a week ago.
This thread was posted less then a week ago.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics
#6
Posted 01 June 2010 - 07:33 PM
I meant Oledb anyway. The code is the same, just replace Odbc with Oledb.


Sign In
Create Account


Back to top









