ASP data retreival problem.

liunx

Guest
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).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.Ok I think that fixed it, 1 more question; does the query contain strings you can edit with Rollno functions?There are some examples here that may help.

<!-- m --><a class="postlink" href="http://www.w3schools.com/ado/ado_examples.aspThat">http://www.w3schools.com/ado/ado_examples.aspThat</a><!-- m --> doesn't deal with Rollno and string functions though.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
%>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.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
 
Back
Top