musicradiolive Posted May 14, 2007 Share Posted May 14, 2007 Hi.On my site i am using a banner rotation system, it displays the ad and goes through to the page i want. I make it send to through.asp?which=NAMEIt gets the name from the database.When it reaches through.asp it enters information into my database to show the ad that was clicked, the data and the time.After it's entered that data i then want it to redirect to the website, but this is where i run into problems.DATABASE: database.mdbtblAdspkAd = Auto NumberFormat = Text (The banner type, 468x60)Link = Memo (The Image Location For The Banner)Name = Text (The name of the banner)InRotation = Yes/No (Is the banner active)Forward = Text (URL of the site)tblAdsLogsID = Auto NumberAdName = Text (The Name Of The Ad Clicked)WhenDate = Date/Time (The Date The Ad Was Clicked) [DEFAULT VALUE=Date()]WhenTime = Date/Time (The Time The Ad Was Clicked) [DEFAULT VALUE=Time()]SCRIPT FOR SHOWING THE AD (Which works fine) <%function ShowAd(format, randomize) Dim conn, rs, str_sql, str_conn, intRsCount Set conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") str_conn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("database.mdb") conn.Open str_conn str_sql = "SELECT * FROM tblAds WHERE Format LIKE '" & format & "' AND InRotation = true" rs.Open str_sql, conn, 1, 2 intRsCount = rs.RecordCount rs.Move(randomize Mod intRsCount) 'There should always be a record here, but it's better to be safe If Not(rs.EOF) Then ShowAd = "<a href=/through.asp?which=" & rs("Name") & " target=_blank><img src=/banners/" & rs("Link") & " border=0></a>" Else ShowAd = "" End If rs.Close conn.Close Set rs = Nothing Set conn = Nothingend function%> <%Dim AdSeedAdSeed = Mid(Now(), Len(Now()) - 4, 2)Response.Write ShowAd("468x60", AdSeed) + "<BR>"%> through.asp <html><head><title>Form to database</title></head><body> <%Dim AdNameDim sConnString, connection, sSQL'Receiving values from Form, assign the values entered to variablesAdName = Request.QueryString("Which")'declare SQL statement that will query the database sSQL = "INSERT into tblAdsLogs (AdName) values ('" & AdName & "')" 'define the connection string, specify database'driver and the location of databasesConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("database.mdb") 'create an ADO connection object Set connection = Server.CreateObject("ADODB.Connection")'Open the connection to the databaseconnection.Open(sConnString)'execute the SQL connection.execute(sSQL)'response.write "The form information was inserted successfully."'Done. Close the connection objectconnection.CloseSet connection = Nothing%><%Dim conn, rs, str_sql, str_conn, which, forwardwhich = Request.QueryString("which")Set conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") str_conn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("database.mdb") conn.Open str_conn str_sql = "SELECT AdName, Forward FROM tblAds WHERE AdName = " & which & "" rs.Open str_sql, conn, 1, 2 response.Write(str_sql)Response.Redirect =rs("Forward")%> The error i'm getting is: Error Type:Microsoft JET Database Engine (0x80040E10)No value given for one or more required parameters./through.asp, line 43Any help is appreciated, this is really driving me mad! lol.Thanks!!Jon Link to comment Share on other sites More sharing options...
justsomeguy Posted May 14, 2007 Share Posted May 14, 2007 Chances are that you have character data in your SQL statement and you left out the quotes. Print out the SQL statement to see what is says. Link to comment Share on other sites More sharing options...
musicradiolive Posted May 14, 2007 Author Share Posted May 14, 2007 Changed bottom of through.asp str_sql = "SELECT tblAds.AdName, tblAds.Forward FROM tblAds WHERE AdName = " & which & "" 'rs.Open str_sql, conn, 1, 2 response.Write(str_sql)'Response.Redirect =rs("Forward") GENERATES::SELECT AdName, Forward FROM tblAds WHERE AdName = Connect Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2007 Share Posted May 15, 2007 "Connect" is string data, it needs single quotes around it. Link to comment Share on other sites More sharing options...
musicradiolive Posted May 15, 2007 Author Share Posted May 15, 2007 str_sql = "SELECT tblAds.AdName, tblAds.Forward FROM tblAds WHERE AdName ='" & which & "'"Still gives the same error though....Or have i mis-understood? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2007 Share Posted May 15, 2007 Right, you would want the query looking like this: SELECT AdName, Forward FROM tblAds WHERE AdName = 'Connect' Try to execute that query directly on the server and see if it throws an error. Link to comment Share on other sites More sharing options...
musicradiolive Posted May 15, 2007 Author Share Posted May 15, 2007 strsql= SELECT AdName, Forward FROM tblAds WHERE AdName = 'Connect' GIVES:Microsoft VBScript compilation (0x800A03EA)Syntax errorstrsql= "SELECT AdName, Forward FROM tblAds WHERE AdName = 'Connect' "GIVES:ADODB.Recordset (0x800A0BB9)Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2007 Share Posted May 15, 2007 Did you try running the query on the server? Open the database server and execute the query directly on it without going through ASP to make sure the query works in the first place. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.