Forum Home
Press F1
 
Thread ID: 34311 2003-06-09 11:06:00 ASP hell (debug my script plz) sc0ut (2899) Press F1
Post ID Timestamp Content User
151341 2003-06-09 11:06:00 plz help
i need help i cant connect to the database
there is something wrong with my line 5 """objDBConn.Open strDBConnect""""
any ideas???

<%
strDBConnect = "Driver={Microsoft Access Driver (*.mdb)};" & "DBQ=data.mdb;"
Set objDBConn = Server.CreateObject("ADODB.Connection")
Set objDBRS = Server.CreateObject("ADODB.Recordset")
objDBConn.Open strDBConnect

strSQL = "INSERT INTO bookings (type, from, depart1, depart2, depart3, depart4, to, return1, return2, return3, return4, passangers, children, infants, class) VALUES (" & Request.Form("type") & ", " & Request.Form("from") & ", " & Request.Form("depart1") & ", " & Request.Form("depart2") & ", " & Request.Form("depart3") & ", " & Request.Form("depart4") & ", " & Request.Form("to") & ", " & Request.Form("return1") & ", " & Request.Form("return2") & ", " & Request.Form("return3") & ", " & Request.Form("return4") & ", " & Request.Form("passangers") & ", " & Request.Form("children") & ", " & Request.Form("infants") & ", " & Request.Form("class") & ");"

Set objDBRS = objDBConn.Execute(strSQL)
'Response.Write strSQL
'Response.End
'Response.Redirect "../index.htm"
%>
sc0ut (2899)
151342 2003-06-10 03:01:00 Hi,

The problem is not actually on line 5, but on the line which that line calls (line 1).

Try this connection string:

set strDBConnect=Server.CreateObject("ADODB.Connection")
strDBConnect.Provider="Microsoft.Jet.OLEDB.4.0"
strDBConnect.Open Server.MapPath("data.mdb")

Also, I would avoid using INSERT INTO like the plague, creating a recordset, and inserting values using a cursor is much much easier.

Did Dreamweaver or something similar write this code, or did you?

If you have dreamweaver, you can create an insert recordset very easily under server behaviours.

However, if that connection string solves your problem, stick with the code you're using below, I've just had terrible trouble making it work!

Good luck,

Erin
Erin Salmon (626)
151343 2003-06-10 03:04:00 Hi - Just for interest's sake, the problem you're having is that when you go:

objDBConn.Open strDBConnect

Where you have defined strDBConnect is causing trouble. ASP Error messages can be very misleading like this, as they may often indicate an error on a line well after the problem itself.

I once had an error on line 1300 or so, and the problem was way back at line 16 where I created the object...

Bummer huh...

:)

Erin
Erin Salmon (626)
151344 2003-06-10 05:09:00 wow thanks for that, i'll try it soon
ASP problems are hard to fix, i'm glad some one knows ASP in this foum
sc0ut (2899)
151345 2003-06-10 05:28:00 Hi,

There are a few others around (who taught me a lot of what I know) on this forum...

I'm not an ASP developer strictly speaking, but you can find plenty who are by subscribing to 2day Internet LTD's ASP Board. Drop by their site (www.2day.com) for details.

Hope you can get it working.

Erin
Erin Salmon (626)
151346 2003-06-10 05:37:00 cool i didn't realize they had a forum
i know lots of web developers use 2day.com but i didn't know about the forum
thanks for that i'll go look at it ;)
sc0ut (2899)
151347 2003-06-10 06:03:00 > I'm not an ASP developer strictly speaking, but you
> can find plenty who are by subscribing to 2day
> Internet LTD's ASP Board. Drop by their site
> (www.2day.com) for details.

I am just been curious here, where on the site is it listed????:|?:| Because I cant find it
stu140103 (137)
151348 2003-06-10 06:09:00 yea i just spend 10 minutes trying to find it
do you have to be a member

another question about 2day.com:
can anyone host a site on 2day.com or is it for businesses
sc0ut (2899)
151349 2003-06-10 06:09:00 Don't forget me!

I was almost surprised to see sc0ut here with an ASP error... considering sc0ut's helped me out of a few sticky ASP situations.

To quote CyberChuck, "ASP errors are a b****".
agent (30)
151350 2003-06-10 06:09:00 Hmmm,

Quite likely they don't show the details if you don't use their services, in which case, posting the details on a public forum might be a little rude. I'll check out what the rules are, and post the details if I'm allowed!

Sorry...

There are countless other ASP Forums on the web www.4guysfromrolla.com (I think it is) have a very comprehensive site, and you can try www.devx.com, www.w3schools.com.

There are dozens of others I've looked at, but don't remember them all off the top of my head.

If I want to know how to do something, I normally jam something like this through google:

+"ASP"+"Read from a text file"

The first returned link tells you exactly how it is done.

developerfusion.com, 123aspx.com, programmersheaven.com - try them...

Google is the best for something specific though - just search for what you want to do.

Cheers,

Erin
Erin Salmon (626)
1 2