Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 6th, 2006, 10:19 AM
Registered User
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query Result to Session Variable

I want to create session variables for Company and Role in the below query:

objCmd = New SqlCommand("SELECT Username, Company, Role FROM A_Users WHERE Username=@givenUsername", objConn)
objCmd.Parameters.AddWithValue("@givenUsername", Username)
objRdr = objCmd.ExecuteReader()

I am a CF Programmer new to .Net. So I am learning how to do .Net on the fly.

Your help is appreciated.

Old April 6th, 2006, 11:15 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

You have to loop through the reader and assign a value into a session variable.

session("Company") = readervalue .. Check the syntax on how to get the reader value.

Similar Threads
Thread Thread Starter Forum Replies Last Post
get the execute query result in variable mahen_pali SQL Server 2005 2 April 7th, 2008 04:04 AM
how to put result of shell function into variable method Beginning VB 6 1 April 20th, 2006 11:42 AM
pass the result of a query to a variable ... eusebio Pro VB Databases 6 March 30th, 2006 07:41 PM
SQL query using a session variable nikcrazyivan Classic ASP Databases 0 March 8th, 2005 12:03 AM
Setting a Variable = Result of a SQL Query PeteS VB Databases Basics 1 June 20th, 2003 08:14 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.