ADO "AddNew"

Results 1 to 2 of 2

Thread: ADO "AddNew"

  1. #1
    tong Guest

    Default ADO "AddNew"

    Hi ASP GURU,<BR> I need to insert a new row of record into a table in SQL2000; the reason that I need the method "AddNew" instead of "INSERT INTO Table ..." is because I need to trace back the KeyID of the inserted row. But somehow this "AddNew" is not working -- no new record is added into my table; but I have verified that "INSERT INTO " statement works perfectly fine. Here&#039;s my coding, hope you can help me or give me an idea.<BR><BR>Coding:<BR>Set rsDATA = Server.CreateObject("ADODB.Recordset")<BR>rsDATA.C ursorLocation = adUseClient<BR>strConn = "Provider=SQLOLEDB; Data Source=Server1-lan; Initial Catalog=National; User Id=INET_Nat; PWD=INET_Nat" <BR><BR>With rsDATA<BR> .Source = "Customers"<BR> .ActiveConnection = strConn<BR> .CursorType = adOpenDynamic<BR> .LockType = adLockOptimistic<BR> .Open<BR> <BR> .AddNew<BR> .Fields("username") = "we" <BR> .Fields("password") = "we" <BR> .Fields("Company") = "er" <BR> .Fields("ContactName") = "er" <BR> .Fields("Address") = "er" <BR> .Fields("City") = "oh" <BR> .Fields("State") = "34" <BR> .Fields("Zip") = "43" <BR> .Fields("Country") = "US" <BR> .Fields("DayPhone") = "45" <BR> .Fields("EvePhone") = "45" <BR> .Fields("Email") = "" <BR> .Fields("MemberDate") = strDateTime <BR> .Update<BR>End With<BR>

  2. #2
    Join Date
    Dec 1969

    Default Did you check ASPFAQs?

    ...and the category Databases, General? And the FAQ there about AddNew?<BR><BR>The only thing I see is that you are using adOpenDynamic where, if you want the ID from the just-added record, you need adOpenKeySet. But read the FAQ.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts