This topic is locked

SQL error

3/29/2009 10:29:59 PM
ASPRunnerPro General questions
B
bhicks11 author

Do you see what's wrong with this? I am trying to show the [Project Name] from the [Project Details] table (which is not the current table) where the [Project Details].[Project Login] = the currently logged in user. I am getting an ASP Error related to the SQL. Any help appreciated.
str = "Select [Project Name] from [PROJECT DETAILS] WHERE [PROJECT DETAILS].[Project Login] = '" & Session("UserID") & "'"
Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

'Response.Write Session(str)

Response.Write rstmp(Session("Project Name"))

rstmp.close

set rstmp=nothing

R
Roger 3/29/2009

Do you see what's wrong with this? I am trying to show the [Project Name] from the [Project Details] table (which is not the current table) where the [Project Details].[Project Login] = the currently logged in user. I am getting an ASP Error related to the SQL. Any help appreciated.

str = "Select [Project Name] from [PROJECT DETAILS] WHERE [PROJECT DETAILS].[Project Login] = '" & Session("UserID") & "'"
Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

'Response.Write Session(str)

Response.Write rstmp(Session("Project Name"))

rstmp.close

set rstmp=nothing


Just a basic question here.
What is this supposed to do: Response.Write rstmp(Session("Project Name")) ???
I think what you want is Response.Write rstmp("Project Name").
This would be the collection element of the record set, RSTMP. rstmp(Session("Project Name")) would cause an issue, because there is no such critter as SESSION("Proejct Name") in the collection.
Just my guess.
Roger

B
bhicks11 author 3/30/2009



Just a basic question here.
What is this supposed to do: Response.Write rstmp(Session("Project Name")) ???
I think what you want is Response.Write rstmp("Project Name").
This would be the collection element of the record set, RSTMP. rstmp(Session("Project Name")) would cause an issue, because there is no such critter as SESSION("Proejct Name") in the collection.
Just my guess.
Roger


By George Roger - I think you are right! I'll give it a try. Thanks so much.

B
bhicks11 author 3/30/2009



Just a basic question here.
What is this supposed to do: Response.Write rstmp(Session("Project Name")) ???
I think what you want is Response.Write rstmp("Project Name").
This would be the collection element of the record set, RSTMP. rstmp(Session("Project Name")) would cause an issue, because there is no such critter as SESSION("Proejct Name") in the collection.
Just my guess.
Roger


Hi Roger,
Though I thought that would fix it - I now have an error relating to the form/page underlying data (of course I can't even modify this). Here it is:
ASP error happened

Technical information

Error number -2147217904

Error description [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

URL /NPDES/TEAM_MEMBERS___LOG_BOOK_COVER_PAGE_print.asp

SQL query SELECT ID, Name, Responsibility, [GSWCC#], Address, City, [State], zip, [Contact Phone Number], [Contact Email], Project, Notes FROM [TEAM MEMBERS - LOG BOOK COVER PAGE] where Project='locustgrovekh'

Solution This error means one of the following:

  1. your query contains parameters. Don't use query with parameters in ASPRunnerPro.
  2. One of field names in SQL query above is incorrect. Make sure all field names in this query are correct.
    Any ideas?
    I checked and these field names are all correct. Thanks again.

R
Roger 3/30/2009

SQL query SELECT ID, Name, Responsibility, [GSWCC#], Address, City, [State], zip, [Contact Phone Number], [Contact Email], Project, Notes FROM [TEAM MEMBERS - LOG BOOK COVER PAGE] where Project='locustgrovekh'

Solution This error means one of the following:

  1. your query contains parameters. Don't use query with parameters in ASPRunnerPro.
    Please see the hilighted portion. Not sure what you are doing here.
    What you probably want is something like this:
    strSQL = "SELECT ID, Name, Responsibility, ..."
    ALSO, this [TEAM MEMBERS - LOG BOOK COVER PAGE] would look like a Calculation to SQL Query Analyzer. You cannot perform a calculation inside a Query, it just doesn't make sense.



    Change the Column names and use a DASH(i.e. -). Spaces can cause all manner of problems. Review your entire DB and Table naming schema as well.
    To query a table that is not the current table (OR any table for that matter...), do something like this:
    strSQL = "select [Project Name] from [Project Table] where Login ID = '" & session("UserID") & " ' "

    (note, example only the actual table or syntax may be a little different for your needs).
    Perhaps you should review the BOL for SQL server and look at the help files for ASPrunner (also search this site for SQL query examples). Unfortunately, your original post and this one is different and what you are looking for seems to have changed.
    Maybe go back to your original post and my reply (re: IsNULL...) and apply that.
    Sorry, not much else I can help with here.
    Roger

A
andie.caron 3/30/2009

ALSO, this [TEAM MEMBERS - LOG BOOK COVER PAGE] would look like a Calculation to SQL Query Analyzer...

Roger


Sorry, I was in error in my last post. When I said use DASHES, what I mean is to remove ALL Spaces and use DASHESto act as a delimeter.
For Example: [TEAM MEMBERS - LOG BOOK COVER PAGE] would become [TEAM-MEMBERS-LOG-BOOK-COVER PAGE]
Sorry, but without seeing exactly what you have as a schema and what you are trying to accomplish, this could be difficult. I suspect that this may be riddled with all manner of potential Gremlins and issues.
Roger.

B
bhicks11 author 3/30/2009

SQL query SELECT ID, Name, Responsibility, [GSWCC#], Address, City, [State], zip, [Contact Phone Number], [Contact Email], Project, Notes FROM [TEAM MEMBERS - LOG BOOK COVER PAGE] where Project='locustgrovekh'

Solution This error means one of the following:

  1. your query contains parameters. Don't use query with parameters in ASPRunnerPro.
    Please see the hilighted portion. Not sure what you are doing here.
    What you probably want is something like this:
    strSQL = "SELECT ID, Name, Responsibility, ..."
    ALSO, this [TEAM MEMBERS - LOG BOOK COVER PAGE] would look like a Calculation to SQL Query Analyzer. You cannot perform a calculation inside a Query, it just doesn't make sense.



    Change the Column names and use a DASH(i.e. -). Spaces can cause all manner of problems. Review your entire DB and Table naming schema as well.
    To query a table that is not the current table (OR any table for that matter...), do something like this:
    strSQL = "select [Project Name] from [Project Table] where Login ID = '" & session("UserID") & " ' "

    (note, example only the actual table or syntax may be a little different for your needs).
    Perhaps you should review the BOL for SQL server and look at the help files for ASPrunner (also search this site for SQL query examples). Unfortunately, your original post and this one is different and what you are looking for seems to have changed.
    Maybe go back to your original post and my reply (re: IsNULL...) and apply that.
    Sorry, not much else I can help with here.
    Roger


Hi Roger, Thanks for the help. For what it's worth my database is in MS Access not SQL Server. The IsNull issue was a different item - not related to this. I thought the [] made it possible to use spaces without problems?
Thanks again.

R
Roger 3/30/2009

Sorry bhicks, my bad. I assumed SQL not Access. In any case, the same holds true.
Also, it's not the SPACESthat are your issue, it's the MINUS SIGN. This make the SQL QUERY ANAYLZER (regardless of SQLor Access) to think you are doing a subtraction mathematical operation.
That's one of the big issues here.
In one of your previous posts, you suggested that you thought you had it fixed (which I assumed was the ISNULLissue).
I still strongly revisiting your scheam, regardless - you are heading for all kinds of trouble.
Anyway, just tryting to help.

B
bhicks11 author 3/31/2009

Sorry bhicks, my bad. I assumed SQL not Access. In any case, the same holds true.

Also, it's not the SPACESthat are your issue, it's the MINUS SIGN. This make the SQL QUERY ANAYLZER (regardless of SQLor Access) to think you are doing a subtraction mathematical operation.
That's one of the big issues here.
In one of your previous posts, you suggested that you thought you had it fixed (which I assumed was the ISNULLissue).
I still strongly revisiting your scheam, regardless - you are heading for all kinds of trouble.
Anyway, just tryting to help.


Thanks Roger - will do. Appreciate your help.