Erollisi Marr - The Nameless

Go Back   Erollisi Marr - The Nameless > EverQuest > Chit-Chat Lounge


Reply
 
Add/Share Add/Share Thread Tools Display Modes
Old 09-16-2002, 11:54 AM   #1
cnjmorris
Guest
 
Posts: n/a
Default .ASP


I am sure this a dumb mistake but I am just not seeing it. Any help would be greatly appreciated.

Okay the following code returns the proper records.

<font color="yellow">
'open and get recordset from tblMembers
MembersSQL = "SELECT * from tblMembers"
Set rsMembers = server.createobject("ADODB.Recordset")
rsMembers.open MembersSQL, conn, 3, 3

Response.Write rsMembers.RecordCount
</font>

When I try and be more selective to a record I want to retrieve it doesn't work for some reason. UserName is a database field. userid is a variable loaded from a Form.Request. I know the userid holds the proper infor because I tested it.

<font color=yellow>
'open and get recordset from tblMembers
MembersSQL = "SELECT * from tblMembers WHERE UserName = ' & userid & '"
Set rsMembers = server.createobject("ADODB.Recordset")
rsMembers.open MembersSQL, conn, 3, 3

Response.Write rsMembers.RecordCount
</font>

I keep getting a "0" return, even though I have checked and the user is there.
  Reply With Quote
Old 09-16-2002, 01:07 PM   #2
Martigan
Guest
 
Posts: n/a

Try...

dim lngCount
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataMembers = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT Count(member_id) AS CountOfMember_id FROM tblMembers where UserName ='" & userid & "'"
cmdTemp.CommandType =1
Set cmdTemp.ActiveConnection = conDataConnection
DataMembers.Open cmdTemp, , 0, 1
lngCount=DataMembers.fields("CountOfMember_id").value
set cmdTemp = nothing
set DataMembers = nothing

  Reply With Quote
Old 09-16-2002, 01:40 PM   #3
Frostwolf Soulsong
Guest
 
Posts: n/a

Looks like the error is in your SQL statement.

If userid is numeric try this....

MembersSQL = "SELECT * from tblMembers WHERE UserName = " & userid

If userid is alphanumeric try this....

MembersSQL = "SELECT * from tblMembers WHERE UserName = '" & userid & "'"

Frosty
  Reply With Quote
Old 09-16-2002, 01:45 PM   #4
cnjmorris
Guest
 
Posts: n/a

Arg, thanks again frosty. I should have posted this hours ago instead of trying everything I could think of 10 times wondering what was wrong.

Syntax kills me. Thanks.
  Reply With Quote
Old 09-16-2002, 02:01 PM   #5
Martigan
Guest
 
Posts: n/a

Still may want to use the COUNT in your SQL query...I've had intermittant problems with the RecordCount property. At times I've had to do a MoveLast then a MoveFirst to get something besides a -1 as my result.

Try using:

"SELECT Count(UserName) as MemberCount from tblMembers WHERE UserName = '" & userid & "'"

and display it using:

Response.Write rsMembers.fields("MemberCount").Value
  Reply With Quote
Old 09-16-2002, 02:13 PM   #6
cnjmorris
Guest
 
Posts: n/a

Martigan, does that apply to access or just sql server? I am using access so a lot of the examples I find don't apply.
  Reply With Quote
Old 09-16-2002, 02:18 PM   #7
Martigan
Guest
 
Posts: n/a

The sample I first gave was from the K`X Web site. I used Access as the database.
  Reply With Quote
Old 09-16-2002, 02:43 PM   #8
Tuan00Dorf
Guest
 
Posts: n/a

Down with Access!
  Reply With Quote
Old 09-16-2002, 02:47 PM   #9
Martigan
Guest
 
Posts: n/a

>>Down with Access!

Yeah I agree...but it's pretty portable...and practical for smallish databases that support guild Web sites.


  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:07 AM.


Powered by: vBulletin. Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.