The script below gives me back a record (i.e. FNAME, LNAME, STUDENTID) that I will bind to a datagrid. After binding, I get value of each cell in the webform datagrid and place it on a webform textbox. Is there a better way to do this so that I skip the datagrid binding and assign the values to a text box directly? Do I have other option other than using a dataReader just like a recordset in VB6?
Thanks
Code:
Dim connectionString As String = "server='SQLSERVER1'; user id='RAUser1'; password='letmein'; database='RA'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [RAUser].* FROM [RAUser] WHERE (([RAUser].[LoginName] = @LoginName) AND ([" & _
"RAUser].[LoginPass] = @LoginPass))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_loginName As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_loginName.ParameterName = "@LoginName"
dbParam_loginName.Value = loginName
dbParam_loginName.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_loginName)
Dim dbParam_loginPass As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_loginPass.ParameterName = "@LoginPass"
dbParam_loginPass.Value = loginPass
dbParam_loginPass.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_loginPass)
dbConnection.Open()
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
Last edited by ARPRINCE; Feb 16th, 2004 at 12:31 PM.
You should have an "Imports System.Data" statement at the top of your pages, change it to "Imports System.Data.SqlClient" and you won't have to use SqlClient in your code.
Originally posted by Memnoch1207 You should have an "Imports System.Data" statement at the top of your pages, change it to "Imports System.Data.SqlClient" and you won't have to use SqlClient in your code.
Would this be on the MyPage.aspx.vb ? At the top of this page I only see (using Visual Studio):
VB Code:
Public Class Login
Inherits System.Web.UI.Page
My HTML code shows only this one:
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb" Inherits="RA.Login"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Login</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
.......