Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ADO

Status
Not open for further replies.

incagold

Programmer
Mar 21, 2003
54
Good morning all,

I am brand new to ADO and am having a problem with understanding how to open a table (MS Access) using ADO in VB6 where the table being opened is for output and contains no current records. Is this done with a connection string? If so could you provide an example? If there are other options, could you also provide some insight? I am lost and need some guidance. The need is rather urgent as the application supports a government program. My sincere thanks in advance for any help.

EAF
 
It sounds like you are thinking of interacting with the table like you would a file. You need to adjust a little bit and think about it as a database instead. If you want to write to a table you do not need to 'open' the table. In fact once you connect to a database, you have opened everything you have rights to access.

When you want to add information to a table in the form of new rows you use an insert statement.

When you change existing rows you use update.

When you read data you use select.

If you are inserting or updating a table and do not need any information returned-- you can do it with a sql statement and your connection-- you could have code like this.
Code:
dim cn as ADODB.Connection
dim sql as string

cn.ConnectionString = "stuff to connect to your database"
cn.Open

string = "insert into [table name] values (stuff, you , want, in, row)"

cn.Execute sql

Of course you would want to have some error trapping and also close the connection when you are done. I would recommend googling for some tutorials on SQL and ADO.
 
Hi stoolpigeon,

Thank you very much for the reply. Like I said I am very new to ADO and guess I need to adjust my thinking as you suggest. Thanks for the suggestion, I will search for some tutorials. Your advice did help me greatly. One of these days I will be up to speed.

EAF
 
incagold: Take a look at this website. It covers ADO very well, with lots of examples. You might also want to look into buying a book on ADO. There are a couple that are very good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top