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

Database adding help please

Status
Not open for further replies.

unborn

Programmer
Jun 26, 2002
362
US
Im new to dealing with databases. I read that using the adodb control and binding the text boxes to it are bad. I have searched everywhere and im a little confused on how to use it with out the control?

I am using the ADODC control it looked more recent. Do i handle this just like an ADODB or am i messing with a completely wrong control?

Im trying to add a client to the database but it just isnt working ive tried attempting to use the control.
Code:
With dbMain.Recordset
    .AddNew
    .Fields("CompanyName") = txtacname
    .Fields("FirstName") = txtAFName
    .Fields("MiddleName") = txtAMInitial
    .Fields("LastName") = txtALName
    .Fields("StreetAddress") = txtAStreet
    .Fields("City") = txtACity
    .Fields("StateOrProvince") = txtAState
    .Fields("PostalCode") = txtAZip
    .Fields("HomePhone") = txtAHome
    .Fields("WorkPhone") = txtAWork
    .Fields("MobilePhone") = txtACell
    .Fields("EmailAddress") = txtAEmail
    .Fields("Birthdate") = txtABDate
    .Fields("DateJoined") = Date
    .Fields("PNotes") = txtAPNotes
    .Update
End With

and i have tried without it.
Code:
dim mCn As ADODB.Connection
Dim mRs As ADODB.Recordset

Set mCn = New ADODB.Connection
Set mRs = New ADODB.Recordset
mCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\my work\Programs\clients.mdb"
mRs.Open "clients", mCn, adOpenKeyset, adLockOptimistic, adCmdTable

this is my attempt with out it ive tried adodb and adodc i cant seem to get either working.

I have the control pointed to a database and on my client form i have text boxes linked automatically. On the main form where im adding them nothing is bound to it other then the contol being set up to use it.

Any help would be much appreciated, perhaps some good tutorials on how to handle databases.

Thanks!

Running in circles is what I do best!
 
If you want to use bound controls, see faq222-3735. There are several other ADO faqs in the Database section of the FAQ page ( which give a mixed view of ADO usage.

If you're looking for samples, try:

THE reference work SQL Books on Line (which every MS database developer should have) is a free download from MS:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Your second approach should work provided you assign the DataField and DataSource property for each bound control. For example:
Code:
  Txtacname.DataField="CompanyName" 'or assign at design time
  TxtAFname.DataField="FirstName"
  ...etc
  Set Txtacname.DataSource = mRs
  Set TxtAFname.DataSource = mRs
  ...etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top