Urgent! Using AddNew Mehod of ADO

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Urgent! Using AddNew Mehod of ADO

  1. #1
    Vipul Desai Guest

    Default Urgent! Using AddNew Mehod of ADO

    Can someone please help me out with an actual example that works<BR>for adding a record to an Access Database. Is it me (I don&#039t think it is) or is it that ADO is an absolute piece of garbarge!<BR>I have never had this problem with DAO, RDO or Oracle Objects For OLE.<BR><BR>Thanks<BR>&#060;%<BR>Dim ADOConn<BR>Dim Daoconn<BR>dIM RS<BR>dim count<BR>Set ADOCOnn = CreateObject("Adodb.Connection") <BR>Set RS = CreateObject("ADODB.REcordSEt") &#039<BR>AdoConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=c est.MDB" <BR><BR>RS.Open "collapsed",adoConn,adOpenDynamic<BR><BR><BR><BR>r s.addnew<BR>RS("LName") = "DESAI"<BR>RS("FName") = "Vipul"<BR>RS.update<BR>Response.WRite Err.Description<BR>%&#062;<BR>&#039Program Crashes Here Noting That the Provider Does Not <BR>&#039Support This Request<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    41

    Default RE: Urgent! Using AddNew Mehod of ADO

    Well, I don&#039t know if ADO is ABSolute garbage. Maybe just a little TLC will do the trick. <BR>I didn&#039t see any definition of the var adOpenDynamic. You can include microsofts adovbs.inc file which declares and sets all ado constants. <BR>Or, you can use 3 which is what adOpenDynamic is set to. <BR><BR>Try this. Please let me know if it solves your problem<BR><BR>faisal@d9.net<BR><BR>&#060;%<BR>Dim ADOConn<BR>Dim Daoconn<BR>dIM RS<BR>dim count<BR>dim adOpenDynamic<BR> adOpenDynamic = 3<BR><BR>Set ADOCOnn = CreateObject("Adodb.Connection") <BR>Set RS = CreateObject("ADODB.REcordSEt") &#039<BR>AdoConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=c est.MDB" <BR><BR>RS.Open "collapsed",adoConn,adOpenDynamic<BR><BR><BR><BR>r s.addnew<BR>RS("LName") = "DESAI"<BR>RS("FName") = "Vipul"<BR>RS.update<BR>Response.WRite Err.Description<BR>%&#062;

  3. #3
    Vipul Desai Guest

    Default RE: DID NOT WORK!

    Thank you for trying to help, but the following code did not<BR>work with your suggestion. I have given all of my code.<BR><BR>&#062;&#062; VIpul<BR><BR><BR><BR>&#060;%@EnableSessionState=Tr ue Language=VBScript%&#062; <BR><BR><BR>&#060;HTML&#062;<BR>&#060;BODY bgColor=CLAY&#062;<BR>&#060;% Call AddLogisticsNumbers %&#062;<BR> <BR><BR>&#060;% Sub AddLogisticsNumbers<BR><BR>Dim ADOConn<BR>dIM ADORS<BR>Dim AdOpenDynamic <BR>adOpenDynamic = 3<BR><BR><BR>Set ADOCOnn = CreateObject("AdoDB.Connection") <BR>ADOConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;data source=C:
    ew.mdb"<BR><BR>Set adors = CreateObject("ADODB.Recordset") <BR><BR>ADORS.Open "Mother", adoCOnn, adOpenDynamic <BR><BR><BR>ADORS.AddNew<BR> ADORS("product") = "This is a test"<BR>ADORS.update<BR>Response Write Err.description<BR><BR><BR><BR><BR><BR><BR><BR><BR >End Sub<BR>%&#062;<BR>&#060;p&#062;<BR>&#060;/HEAD&#062;<BR>&#060;/BODY&#062; <BR>&#060;/HTML&#062;<BR><BR>

  4. #4
    John Weeflaar Guest

    Default RE: Urgent! Using AddNew Mehod of ADO

    Replace<BR>Set ADOCOnn = CreateObject("Adodb.Connection") <BR>Set RS = CreateObject("ADODB.REcordSEt") &#039<BR><BR>with<BR><BR>Set ADOCOnn = Server.CreateObject("Adodb.Connection")<BR>Set RS = Server.CreateObject("ADODB.RecordSet") <BR><BR> <BR>Cheers,<BR><BR>John<BR>


  5. #5
    Vipul Desai Guest

    Default RE: Urgent! Using AddNew Mehod of ADO

    &#060;%@EnableSessionState=True Language=VBScript%&#062; <BR>&#060;! -- #Include File = "c:Progra~1Common~1SystemadoADOVBS.INC"--&#062; <BR>&#060;HTML&#062;<BR>&#060;BODY bgColor=CLAY&#062;<BR>&#060;% Call AddLogisticsNumbers %&#062;<BR><BR>&#060;% Sub AddLogisticsNumbers<BR><BR>Dim ADOConn<BR>Dim ADORS<BR>dim AdOpenDynamic <BR>adOpenDynamic = 3<BR><BR>Set ADOCOnn = Server.CreateObject("AdoDB.Connection") <BR>ADOConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;data source=C:
    ew.mdb"<BR><BR>Set adors = Server.CreateObject("ADODB.Recordset") <BR><BR>ADORS.Open "Mother", adoCOnn,2<BR><BR> <BR><BR>ADORS.AddNew<BR>ADORS("product") = "This is a test"<BR><BR>ADORS.update<BR>Response.Write Err.description<BR><BR><BR><BR><BR><BR><BR><BR><BR >End Sub<BR>%&#062;<BR>&#060;p&#062;<BR>&#060;/HEAD&#062;<BR>&#060;/BODY&#062; <BR>&#060;/HTML&#062;<BR><BR>

  6. #6
    John Weeflaar Guest

    Default RE: Urgent! Using AddNew Mehod of ADO

    Hi Vipul,<BR><BR>I guess it means it works doesn&#039t it (or it doesn&#039t?).<BR>Let me know if it doesn&#039t.<BR><BR>Cheers,<BR><BR>John

  7. #7
    Vipul Desai Guest

    Default RE: Addnew Method: No, It Does Not Work!

    Can someone help me out here with using the AddNew method with <BR>ADO.<BR><BR>Thanks, Vipul<BR><BR><BR><BR><BR>&#060;%@EnableSessionStat e=True Language=VBScript%&#062; <BR>&#060;! -- #Include File = "c:Progra~1Common~1SystemadoADOVBS.INC"--&#062; <BR><BR><BR>&#060;HTML&#062;<BR>&#060;BODY bgColor=CLAY&#062;<BR>&#060;% Call AddLogisticsNumbers %&#062;<BR>&#060;% Sub AddLogisticsNumbers<BR><BR>Dim ADOConn<BR>Dim ADORS<BR>dim AdOpenDynamic <BR>adOpenDynamic = 3<BR><BR>Set ADOCOnn = Server.CreateObject("AdoDB.Connection") <BR>ADOConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;data source=C:
    ew.mdb"<BR><BR>Set adors = Server.CreateObject("ADODB.Recordset") <BR>ADORS.Open "Mother", adoCOnn,adOpenDynamic<BR> &#039adOpenDynamic = 3 <BR><BR> <BR><BR>ADORS.AddNew<BR>ADORS("product") = "This is a test"<BR><BR>ADORS.update<BR>Response.Write Err.description<BR>&#039Error Generated states that the provider does not support this function <BR><BR><BR><BR><BR>End Sub<BR>%&#062;<BR>&#060;p&#062;<BR>&#060;/HEAD&#062;<BR>&#060;/BODY&#062; <BR>&#060;/HTML&#062;<BR><BR>

  8. #8
    John Weeflaar Guest

    Default RE: Addnew Method: No, It Does Not Work!

    I think you&#039ve got a syntax problem with the connection, and SQL string for the recordset.<BR>Try this:<BR>instead of<BR>Set ADOCOnn = Server.CreateObject("AdoDB.Connection") <BR>ADOConn.Open "Provider = Microsoft.Jet.OLEDB.4.0;data source=C:
    ew.mdb"<BR>replace it with this to test:<BR>&#039put this strconn string in one line<BR>strconn = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("new.mdb") & ";"<BR>Set ADOConn = Server.CreateObject("AdoDB.Connection") <BR>ADOConn.Open strconn<BR>Set adors = Server.CreateObject("ADODB.Recordset") <BR>SQL = "SELECT * FROM Product" &#039assuming Product is the table &#039name <BR>adors.Open SQL, adoConn,1,3<BR>adors.AddNew<BR>adors("product") = "This is a test"<BR>adors.update<BR><BR>You have to create an SQL string for the recordset.

  9. #9
    Stephen Fisher Guest

    Default RE: Urgent! Using AddNew Mehod of ADO

    ADO works exactly as documented. For example, documented is the default lock type of a recordset.<BR><BR>adLockReadOnly (Default) Read-only—you cannot alter the data. <BR><BR>This is the problem.<BR><BR>This is the 4th parameter of the recordset.<BR>What I use, which is simpler to read is,<BR><BR>rs.CursorLocation = adUseServer<BR>rs.CursorType = adOpenStatic<BR>rs.LockType = adLockOptimistic<BR>rs.Open "table", cnConn

  10. #10
    Join Date
    Dec 1969
    Posts
    1,912

    Default RE: Urgent! Using AddNew Mehod of ADO

    This works on my system. <BR><BR>Set Conn=Server.CreateObject("ADODB.Connection")<BR>Se t objRec=Server.CreateObject("ADODB.RecordSet")<BR>s ql="SELECT * FROM tblpm"<BR>objRec.Open sql,Conn,3,3 &#039appears you are missing the second operator<BR><BR>objRec.AddNew<BR>objRec.Fields("pm name")=pmname<BR>objRec.Fields("pmnumber")=pmnumbe r<BR>objRec.Fields("pmdescription")=pmdescription< BR>objRec.Fields("pmopr")=squadronid<BR>objRec.Fie lds("pmocr")=pmocr<BR>objRec.Fields("pmreportfreq" )=pmreportfreq <BR>objRec.Fields("pmassume")=pmassume<BR>objRec.F ields("wingtaskid")=wingtaskid<BR>objRec.Fields("u serid")=userid<BR>objRec.Fields("dodid")=dodid<BR> objRec.Fields("nafid")=nafid<BR>objRec.Fields("maj comid")=majcomid<BR>objRec.Fields("wingid")=wingid <BR>objRec.Fields("groupid")=groupid<BR>objRec.Fie lds("squadronid")=squadronid<BR>objRec.Update<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
  •