How do I figure out what I am adding to my DB....(

Results 1 to 2 of 2

Thread: How do I figure out what I am adding to my DB....(

  1. #1
    JL Guest

    Default How do I figure out what I am adding to my DB....(

    Here is the code I am using, in simiplfied form. Basicly I am trying to add a new Record to my database and then determine what the ID field of that record is. The ID field is generated by the database, it is an ID (autonumbered integer) field. The Response.Write at the end of the code returns nothing.<BR><BR>I have already tried the Requery and Resync methods with no luck. Requery returns bad data, and resync doesnt seem to be supported for addnew created records. Since none of the data fields are unique, running a query on the db after the insert seems problimatic to me. I guess I could query the db and .movelast, but that doesnt seem right to me. Any ideas?<BR><BR>IIS4, SQL7, NT4<BR><BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;!--#include file="adovbs.txt"--&#062;<BR><BR>&#060;%<BR> Dim strConnectionString, _<BR> strTableName, _<BR> strSQL, _<BR> newrow<BR><BR> strConnectionString = Request("ConnectionString")<BR> strTableName = Request("TableName")<BR><BR> Dim objRS, objConn<BR> Set objConn = Server.CreateObject("ADODB.Connection")<BR> objConn.Open strConnectionString<BR><BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> objRS.Open strTableName, objConn, , adLockPessimistic, adCmdTable<BR><BR> objRS.AddNew<BR><BR> objRS("Data1")=Request("Data1")<BR> objRS("Data2")=Request("Data2")<BR> objRS("Data3")=Request("Data3")<BR> objRS("Data4")=Request("Data4")<BR> <BR> objRS.Update <BR><BR> newrow = objRS.Fields("ID")<BR> <BR> objRS.Close<BR><BR> response.write newrow<BR><BR> &#039Clean up<BR> objRS.Close<BR> Set objRS = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR>%&#062;<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: How do I figure out what I am adding to my DB.

    Try this article:<BR><BR><BR><BR>Todd<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