Connection and Recordset to SQL Server

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Re: Connection and Recordset to SQL Server

    Why are you grabbing the entire table in a SELECT statement, simply to add a
    new row?

    How about:

    Set objConn1 = CreateObject("ADODB.Connection")
    objConn1.Open "<connection string>"
    objConn1.Execute "INSERT Customer(textColumn) VALUES('" & strText & "')"

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Erik" <nospam@nospam.com> wrote in message
    news:echQkpF4DHA.2332@TK2MSFTNGP10.phx.gbl...
    > I'm using ASP 3.0 and SQL Server 2000. I keep getting this error:
    >
    > a.. Error Type:
    > ADODB.Recordset (0x800A0BB9)
    > Arguments are of the wrong type, are out of acceptable range, or are in
    > conflict with one another.
    > /databaseconect.asp, line 22
    >
    > It seems to have to do with the lock or cursor type in SQL Server. Here is
    > my code. Please help
    >
    > <%@ Language=VBScript %>
    > <%
    > strText = Request.Form("textfield")
    > Dim objconn1 'Connection Object
    > Dim strconn1
    >
    > Set objConn1 = Server.CreateObject("ADODB.Connection")
    > strconn1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
    > Info=False;Initial Catalog=Northwind;Data Source=SERVER\SERVER"
    > objconn1.Open strconn1
    >
    > ''Recordset Info
    > Set rs1 = Server.CreateObject("ADODB.Recordset")
    >
    > rs1.Open "SELECT customername FROM Customer", objconn1, adOpenDynamic,
    > adLockOptimistic, adCmdText
    > rs1.AddNew
    > rs1.Fields("textfield") = strText
    > rs1.Update
    > %>
    >
    >
    >
    >
    >

    Aaron Bertrand - MVP Guest

  2. Similar Questions and Discussions

    1. Error with local test server - cannot add recordset
      :confused; Hi I am relatively new to this and learning via Dreamweaver's help but encountered problem. Running on Win2K and installed IIS...
    2. Problem with Recordset from SQL Server
      I have just upsized an Access database to MS SQL and have begun converting and testing ASP pages created in Dreamweaver. After creating a Recordset...
    3. response.redirect and recordset/connection object?
      I have the following code. Should I close and release the database objects before run response.redirect("some url")? or will the response.redirect...
    4. recordset not returning value from SQL server
      HI There, I am having a little trouble displaying a recordset from SQL Server and I was wondering if someone could have a look at my code to see...
    5. Connection error: ADODB.Recordset (0x800A0E7D)
      I have been copying and pasting code and this has been working, but now I get this error: Error Type: ADODB.Recordset (0x800A0E7D) Operation is...
  3. #2

    Default Connection and Recordset to SQL Server

    I'm using ASP 3.0 and SQL Server 2000. I keep getting this error:

    a.. Error Type:
    ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in
    conflict with one another.
    /databaseconect.asp, line 22

    It seems to have to do with the lock or cursor type in SQL Server. Here is
    my code. Please help

    <%@ Language=VBScript %>
    <%
    strText = Request.Form("textfield")
    Dim objconn1 'Connection Object
    Dim strconn1

    Set objConn1 = Server.CreateObject("ADODB.Connection")
    strconn1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
    Info=False;Initial Catalog=Northwind;Data Source=SERVER\SERVER"
    objconn1.Open strconn1

    ''Recordset Info
    Set rs1 = Server.CreateObject("ADODB.Recordset")

    rs1.Open "SELECT customername FROM Customer", objconn1, adOpenDynamic,
    adLockOptimistic, adCmdText
    rs1.AddNew
    rs1.Fields("textfield") = strText
    rs1.Update
    %>





    Erik Guest

  4. #3

    Default Re: Connection and Recordset to SQL Server

    Thanks. It worked. How do I account for the primary key field in SQL Server
    2000. I get the error that the insert failed because the table has a primary
    key that cannot be NULL.

    Thanks.


    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:OHeBurF4DHA.2404@TK2MSFTNGP10.phx.gbl...
    > Why are you grabbing the entire table in a SELECT statement, simply to add
    a
    > new row?
    >
    > How about:
    >
    > Set objConn1 = CreateObject("ADODB.Connection")
    > objConn1.Open "<connection string>"
    > objConn1.Execute "INSERT Customer(textColumn) VALUES('" & strText & "')"
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    > "Erik" <nospam@nospam.com> wrote in message
    > news:echQkpF4DHA.2332@TK2MSFTNGP10.phx.gbl...
    > > I'm using ASP 3.0 and SQL Server 2000. I keep getting this error:
    > >
    > > a.. Error Type:
    > > ADODB.Recordset (0x800A0BB9)
    > > Arguments are of the wrong type, are out of acceptable range, or are in
    > > conflict with one another.
    > > /databaseconect.asp, line 22
    > >
    > > It seems to have to do with the lock or cursor type in SQL Server. Here
    is
    > > my code. Please help
    > >
    > > <%@ Language=VBScript %>
    > > <%
    > > strText = Request.Form("textfield")
    > > Dim objconn1 'Connection Object
    > > Dim strconn1
    > >
    > > Set objConn1 = Server.CreateObject("ADODB.Connection")
    > > strconn1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
    Security
    > > Info=False;Initial Catalog=Northwind;Data Source=SERVER\SERVER"
    > > objconn1.Open strconn1
    > >
    > > ''Recordset Info
    > > Set rs1 = Server.CreateObject("ADODB.Recordset")
    > >
    > > rs1.Open "SELECT customername FROM Customer", objconn1, adOpenDynamic,
    > > adLockOptimistic, adCmdText
    > > rs1.AddNew
    > > rs1.Fields("textfield") = strText
    > > rs1.Update
    > > %>
    > >
    > >
    > >
    > >
    > >
    >
    >

    Biggie Guest

  5. #4

    Default Re: Connection and Recordset to SQL Server

    You will need to insert the primary key columns as well.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Biggie" <nospam@nospam.com> wrote in message
    news:egaza3F4DHA.2080@TK2MSFTNGP11.phx.gbl...
    > Thanks. It worked. How do I account for the primary key field in SQL
    Server
    > 2000. I get the error that the insert failed because the table has a
    primary
    > key that cannot be NULL.
    >
    > Thanks.
    >
    >
    > "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    > news:OHeBurF4DHA.2404@TK2MSFTNGP10.phx.gbl...
    > > Why are you grabbing the entire table in a SELECT statement, simply to
    add
    > a
    > > new row?
    > >
    > > How about:
    > >
    > > Set objConn1 = CreateObject("ADODB.Connection")
    > > objConn1.Open "<connection string>"
    > > objConn1.Execute "INSERT Customer(textColumn) VALUES('" & strText & "')"
    > >
    > > --
    > > Aaron Bertrand
    > > SQL Server MVP
    > > [url]http://www.aspfaq.com/[/url]
    > >
    > >
    > >
    > >
    > > "Erik" <nospam@nospam.com> wrote in message
    > > news:echQkpF4DHA.2332@TK2MSFTNGP10.phx.gbl...
    > > > I'm using ASP 3.0 and SQL Server 2000. I keep getting this error:
    > > >
    > > > a.. Error Type:
    > > > ADODB.Recordset (0x800A0BB9)
    > > > Arguments are of the wrong type, are out of acceptable range, or are
    in
    > > > conflict with one another.
    > > > /databaseconect.asp, line 22
    > > >
    > > > It seems to have to do with the lock or cursor type in SQL Server.
    Here
    > is
    > > > my code. Please help
    > > >
    > > > <%@ Language=VBScript %>
    > > > <%
    > > > strText = Request.Form("textfield")
    > > > Dim objconn1 'Connection Object
    > > > Dim strconn1
    > > >
    > > > Set objConn1 = Server.CreateObject("ADODB.Connection")
    > > > strconn1 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
    > Security
    > > > Info=False;Initial Catalog=Northwind;Data Source=SERVER\SERVER"
    > > > objconn1.Open strconn1
    > > >
    > > > ''Recordset Info
    > > > Set rs1 = Server.CreateObject("ADODB.Recordset")
    > > >
    > > > rs1.Open "SELECT customername FROM Customer", objconn1,
    adOpenDynamic,
    > > > adLockOptimistic, adCmdText
    > > > rs1.AddNew
    > > > rs1.Fields("textfield") = strText
    > > > rs1.Update
    > > > %>
    > > >
    > > >
    > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Mark Schupp Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139