Author |
Topic |
|
psalesses
New Member
50 Posts |
Posted - 25 March 2002 : 13:17:38
|
I'm trying to write an sql statement that would check the database to see if there is already a value with that name in the DB.
When people register, they enter the site name they want, then the script should go into the table, select the sitedirectory column and see whether or not there is a value in that column with the same value...
<% sitedirectory = "LBBruins" strSql = "SELECT * FROM teamsites WHERE sitedirectory = sitedirectory" %>
when i execute that code, it gives me this:
[Microsoft][ODBC SQL Server Driver][SQL Server]The text, ntext, and image data types cannot be used in the WHERE, HAVING, or ON clause, except with the LIKE or IS NULL predicates.
/teamsites/scripts/register/step2_inc.asp, line 22
any ideas how I could check the db if I cant use where?!?!
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 25 March 2002 : 13:32:14
|
You may have problems with the column types you are using. Before that it looks like you are making a mistake when creating the SQL Query. Probably it should go like this:
strSql = "SELECT * FROM teamsites WHERE sitedirectory =""" & sitedirectory & """;"
You may have to change the operator used for the comparison depending on the type of the sitedirectory field. I'm just saying this because of the error message.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
psalesses
New Member
50 Posts |
Posted - 25 March 2002 : 14:23:36
|
changing it to your string got rid of the error with the "cant use where statement" but now it gave me this one:
Code: sitedirectory = "lbbruins" strSql = "SELECT sitedirectory FROM teamsites WHERE sitedirectory=""" & sitedirectory & """;"
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'lbbruins'.
/teamsites/scripts/register/step2_inc.asp, line 10
any ideas now?
|
|
|
nomad_2k
Junior Member
United Kingdom
173 Posts |
Posted - 25 March 2002 : 14:51:49
|
I don't think double quotes (") work in sql you need to use single quotes (') like this:
strSql = "SELECT * FROM teamsites WHERE sitedirectory ='" & sitedirectory & "';"
|
|
|
|
Topic |
|