Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Need help!

  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Need help!

    I alwayz will get a error of saying the database perform multiple ODBC.I wonder is it because of the programme_Id cannot be insert two times?But It is suppose to be inserted into two different databases.

    These are my codes:

    'Get the form values
    Programme_Name = Request.Form("ProgrammeName")
    'country = Request.Form("country")
    StartDate = ConvertDate(Request.Form("StartDate"))
    EndDate = ConvertDate(Request.Form("EndDate"))
    description = Request.Form("description")
    executiveSummary = Request.Form("ExecutiveSummary")
    format = Request.Form("format")
    contentDevelopment = Request.Form("contentDevelop")
    ApartmentAllocate = Request.Form("ApartmentAllocate")
    skillsRequire = Request.Form("skillsRequire")
    objectives = Request.Form("submit_KeyPoints")
    url = Request.Form("url")
    referralSource = Request.Form("referralSource")
    otherRemarks = Request.Form("otherRemarks")
    organization = Request.Form("organization")
    NoOfParticipants = Request.Form("NoOfParticipants")
    'country = Request.Form("sCountry")
    country = Request.Form("v")


    'Get an empty recordset
    sqlString = "SELECT * FROM Programme WHERE 1=2"

    Set RS_InsertProgrammme = Server.CreateObject("ADODB.RecordSet")
    RS_InsertProgrammme.Open sqlString, ConDB, 2,3,1

    'Assign the values to the record
    RS_InsertProgrammme.AddNew
    RS_InsertProgrammme("Programme_ID") = programmeid
    RS_InsertProgrammme("Programme_Name") = trim(Programme_Name)
    RS_InsertProgrammme("Start_Date") = CDate(StartDate)
    RS_InsertProgrammme("End_Date") = CDate(EndDate)
    RS_InsertProgrammme("duration") = Int(Duration)
    RS_InsertProgrammme("Description") = FormatTextIntoDB(trim(description))
    RS_InsertProgrammme("Format") = FormatTextIntoDB(trim(description))
    RS_InsertProgrammme("Content_development") = FormatTextIntoDB(trim(description))
    RS_InsertProgrammme("Skills_requirement") = FormatTextIntoDB(trim(description))
    RS_InsertProgrammme("Apartment_Allocation") = FormatTextIntoDB(trim(description))
    RS_InsertProgrammme("Executive_Summary") = FormatTextIntoDB(trim(executiveSummary))
    RS_InsertProgrammme("Programme_objectives") = FormatTextIntoDB(trim(keyPoints))
    RS_InsertProgrammme("Referral_Source") = trim(referralSource)
    RS_InsertProgrammme("Other_Remarks") = FormatTextIntoDB(trim(otherRemarks))
    RS_InsertProgrammme("No_of_Participants") = Int(noOfPaticipants)
    RS_InsertProgrammme("Visiting_Org") = Int(organization)
    RS_InsertProgrammme("URL") = trim(url)


    RS_InsertProgrammme.Update

    RS_InsertProgrammme.Close
    Set RS_InsertProgrammme = Nothing

    ' Get an empty recordset for the country
    sqlstring = "SELECT * FROM Programme_Country WHERE 1=2"

    Set RS_InsertCountry = Server.CreateObject("ADODB.RecordSet")
    RS_InsertCountry.Open sqlString, ConDB, 2,3,1

    'Assign the values to the record
    RS_InsertCountry.AddNew
    RS_InsertCountry("Programme_ID") = programmeid RS_InsertCountry("Country") = FormatTextIntoDB(trim(country))

    RS_InsertCountry.Update

    RS_InsertCountry.Close
    Set RS_InsertCountry = Nothing


    Session("Programme_ID") = programmeid
    Session("Programme_Name") = Request.form("ProgrammeName")
    Session("Start_Date") = Request.form("StartDate")
    Session("End_Date") = Request.form("EndDate")
    Session("Country") = Request.form("sCountry")

    ConDB.Close
    Set ConDB = Nothing

    Response.Redirect "../Visitors/visitors.asp"
    %>
    Thanks for all of you for helping.God bless you~

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Few questions :

    1. Did you create a connection (like below ?)

    dim conExample
    set conExample=server.CreateObject("adodb.connectionconGranIT.Open("provider=microsoft.jet.oledb.4.0;dat a source="&server.MapPath("example.mdb"))

    2. Why do you use these empty recordsets. Why don't you simply use an "insert -sqlstatement"?

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes i got set the connection.
    I got try not to create a new recordset but it dont works also.
    Thanks for all of you for helping.God bless you~

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm also at a loss as to why you are retreiving an empty recordset - that might be causing the problem since the code you wrote looks very confusing (?!?) ;

    I haven't looked at your database structure, but try doing something else, like using an INSERT INTO statement:

    insertquery = "INSERT INTO table_name (fieldname1,fieldname2) VALUES ('" & fieldname1 & "','" & fieldname2 & "')"
    Set rs = Conn.Execute(insertquery)

    Also, I see you creating a recordset, but not an actual connection:

    Set Conn = Server.CreateObject(ADODB.Connection)

    What exactly is the error that you're getting?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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