PDA

View Full Version : ASP data retreival problem.


GameSnaKe
10-23-2004, 02:44 AM
Can anyone tell me how to retrieve data using a SELECT and WHERE statement. I want to get the "Name, AGE, Class of a student WHERE RollNo=something" The RollNo I entered in a textbox. I used SQL Server and ASP(Not ASP.Net).

eRad
10-23-2004, 11:49 AM
SELECT Name, Age, Class FROM TableName WHERE RollNo=SomeNum

the tablename is the table that contains name, age and class fields. if they are in separate tables the statement will be slightly different, but otherwise that should be ok. Keep in mind that there should be no quotations around the SomeNum, since it is a number field. If it's a string you need them, and FYI if it's a date you use #'s.

GameSnaKe
10-23-2004, 01:29 PM
Ok I think that fixed it, 1 more question; does the query contain strings you can edit with Rollno functions?

Doug G
10-23-2004, 06:31 PM
There are some examples here that may help.

http://www.w3schools.com/ado/ado_examples.asp

GameSnaKe
10-24-2004, 02:48 AM
That doesn't deal with Rollno and string functions though.

eRad
10-24-2004, 02:47 PM
not sure what you mean, but i'm guessing what you're trying to do is set the RollNo value to a variable?

if so this is how:

<%
Dim RollNum As Integer
Dim SQL As String
sql = "SELECT Name, Age, Class FROM TableName WHERE RollNo = " & RollNum
%>

afterburn
10-25-2004, 10:47 AM
That will only work In VB6. VBScript does not allow for as statements, they nothing is type safe in VBScript, all variables are VARIANT type.

Its a huge union casting structure. That will work in VB.net or VB6 but not in ASP/VBScript.

eRad
10-25-2004, 11:41 AM
Originally posted by afterburn
That will only work In VB6. VBScript does not allow for as statements, they nothing is type safe in VBScript, all variables are VARIANT type.

Its a huge union casting structure. That will work in VB.net or VB6 but not in ASP/VBScript.
Oops.. been doing too much .NET lately!

anyway aside from variable declarations i hope you get the idea GS