View Full Version : Need help!

08-10-2002, 12:04 PM
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("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)


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("Programme_ID") = programmeid RS_InsertCountry("Country") = FormatTextIntoDB(trim(country))


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")

Set ConDB = Nothing

Response.Redirect "../Visitors/visitors.asp"

08-13-2002, 10:31 AM
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;data source="&server.MapPath("example.mdb"))

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

08-13-2002, 08:43 PM
Yes i got set the connection.
I got try not to create a new recordset but it dont works also.

08-14-2002, 12:42 AM
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?