Error in writing to a database

Discussion in 'C#' started by Cheryl399, May 7, 2010.

  1. #1
    Hello everyone,

    Im trying to write to a database but i keep getting an error, for some reason it doesnt like my connection string even though i have connectivity to the database:

    ADODB.Command (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    My code is:

    Set strCon = Server.CreateObject ("ADODB.Command")

    strCon.ActiveConnection = MM_MyDSN_STRING <Stops at this line

    Any help would be appreciated

    Thanks :)
     
    Cheryl399, May 7, 2010 IP
  2. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does your script include the adovbs.inc file ?
     
    50plus, May 9, 2010 IP
  3. Cheryl399

    Cheryl399 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes it does, i have this <!-- #include virtual="testproject/common/adovbs.inc" --> at the top of the page
     
    Cheryl399, May 9, 2010 IP
  4. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can you post some more of your code because "strCon.ActiveConnection = MM_MyDSN_STRING" is not the problem, it's what comes before that, i.e. the values you want to write and the sql string.
     
    50plus, May 10, 2010 IP
  5. Cheryl399

    Cheryl399 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I changed strCon.ActiveConnection because i thought that might have been the problem, but here is more of my code:

    <%

    <!-- #include virtual="testproject/common/adovbs.inc" -->
    <!--#include file="Connections/MyDSN.asp" -->

    Dim Problem_ID
    Dim Priotiy_Level
    Dim Problem_Site
    Dim Problem_Description
    Dim Problem_Status
    Dim Job_Status
    Dim Tempvar1, Tempvar2, Tempvar3, Tempvar4, Tempvar5, Tempvar6

    Dim UserRequestRS
    Dim strConn
    Dim strSQL
    Dim MM_MyDSN_STRING

    Tempvar1 = Request.Form("ProblemID")
    Tempvar2 = Request.Form("PriotiyLevel")
    Tempvar3 = Request.Form("ProblemSite")
    Tempvar4 = Request.Form("ProblemDescription")
    Tempvar5 = Request.Form("ProblemStatus")
    Tempvar6 = Request.Form("JobStatus")


    Response.write "<p> " & Tempvar1 & " </p>"
    Response.write "<p> " & Tempvar2 & " </p>"
    Response.write "<p> " & Tempvar3 & " </p>"
    Response.write "<p> " & Tempvar4 & " </p>"
    Response.write "<p> " & Tempvar5 & " </p>"
    Response.write "<p> " & Tempvar6 & " </p>"

    Set strConn = Server.CreateObject ("ADODB.Connection")

    strConn.ConnectionString = MM_MyDSN_STRING


    set UserRequestRS = Server.Createobject("ADODB.Recordset")


    strSQL= "SELECT * FROM DeskTable"

    strConn.open

    UserRequestRS.Open strSQL, strConn, 3,2



    UserRequestRs.AddNew
    UserRequestRs.Update
    UserRequestRs.Fields("Problem_ID").value= ProblemID
    UserRequestRs.Fields("Priotiy_Level").value= PriotiyLevel
    UserRequestRs.Fields("Problem_Site").value= ProblemSite
    UserRequestRs.Fields("Problem_Description").value= ProblemDescription
    UserRequestRs.Fields("Problem_Status").value= ProblemStatus
    UserRequestRs.Fields("Job_Status").value= JobStatus
    UserRequestRs.Update


    SQL= "INSERT INTO DeskTable (Problem_ID,Priotiy_Level,Problem_Area,Problem_Description,Problem_Status,Job_Status)"

    SQL= SQL & " VALUES "
    SQL= SQL & "(" & Problem_ID & "',"
    SQL= SQL & "'" & Priotiy_Level & "',"
    SQL= SQL & "'" & Problem_Site & "',"
    SQL= SQL & "'" & Problem_Description & "',"
    SQL= SQL & "'" & Problem_Status & "',"
    SQL= SQL & "'" & Job_Status & "')"

    strConn.Execute SQL

    Response.Write("Thank you for your request")

    set UserRequestRS = nothing

    Set strConn = Nothing

    %>
     
    Cheryl399, May 10, 2010 IP
  6. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The first thing to check and correct is the discrepancy in naming, i.e. you have everywhere

    ProblemSite or Problem_Site

    yet in your sql statement you have :

    SQL= "INSERT INTO ............... Problem_Area

    make sure that you use the exact form name and the exact table field name.
     
    50plus, May 10, 2010 IP