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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO connect, don't really know what I am doing!

Status
Not open for further replies.

SwanSong4

MIS
Jul 19, 2001
9
US
Using ADO, how do I connect to a database? I am just looking for something that will connect, I have my record source and connection string in the properties done. BOF action is set to 0-adDoMoveFirst and EOF action is 2-adDoAddNew.
The name is ADOaddnew.
With this said.. and this is the code for my ADD Record button.

FrmPage1.AdoAddNew.Recordset.MoveFirst
FrmPage1.AdoAddNew.Recordset.Find "AMQTE = '" & Trim(TxtQuotenumber.Text) & "'"
If FrmPage1.AdoAddNew.EOFAction Then
FrmPage1.AdoAddNew.Recordset.AddNew
blnNewpksave = True

some of it, I think I am going about this all wrong anyway.
 
There are several ways to connect to a database, so if you find one that works and makes sense to you, use it.

You've set the Connection String and RecordSource for the Adodc1, the next thing is to bind some controls to that Adodc1. Use textboxes (or whatever) and set each one's DataSource to Adodc1 (if done properly, Adodc1 will be in the dropdown). Once you have the DataSource for each textbox setup, the last thing to do is set the DataField for each. The DataField is the name of the field in the database you want that textbox to display (which should also appear in the dropdown).

I recommend setting the EOF action to adDoMoveLast, because your code is looking for duplicates on add new. If the recordset doesn't find the specified criteria, EOF will be true, and thus so will add new. At this point, calling add new again will probably make it complain.

Hope this helps!

-Mike Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
I would not recommend using the ADO Data Control.

Connect Like This:
dim cnConnection as ADODB.connection

Set cnConnection = Createobject("ADODB.Connection")

cnConnection.connectionstring = "provider=MSDAORA;data source=NAMEofYourSERVER;user id=YourUserName;password=YourPassword"

cnConnection.Open

'You can also use the ODBC driver for ORACLE. Here is the syntax for the connection string:
"driver={Microsoft ODBC for ORACLE};server=SERVER;uid=UserName;pwd=Password"

Thanks Billy! Anna Ball
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top