home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

gathering db fields in var

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2102
Discussions: 200,948, Posts: 2,379,406, Members: 246,309
Old November 14th, 2004, 01:35 AM   Digg it!   #1 (permalink)
Member
 
Join Date: Oct 2003
Posts: 263
gathering db fields in var

Hi guys,

I am using vb.net. I was wondering how to do something that I have found a work around for. Basically lets say I am creating a log-in page. When the user clicks log in I run sql to find the user name and pw. I then have 2 hidden text fields that are linked to the database fields. Then i say if txtUsername.text=txtHiddentext.text and txtpw.text=txthiddenpw.text then show main page.

I was basically wondering how do i grab a database field and put it into a variable instead of hiding a text box field? i know there is a way to do it but not to sure how. Thanks for your help guys.
amtrac24 is offline   Reply With Quote
Old November 14th, 2004, 12:53 PM     #2 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
What do you mean put them into a variable? Theres not much to it:

Dim UserName As String
Dim Password As String
UserName = YourDataRow.Item("UserName")
Password = YourDataRow.Item("Password")


or you could use sessions variables:

Session("UserName")=
Creosote is offline   Reply With Quote
Old November 14th, 2004, 01:34 PM     #3 (permalink)
Member
 
Join Date: Oct 2003
Posts: 263
sorry for anther stupid question. How do you configure the datarow? I dont use or dont know how to use a datarow when connecting to a db. Thanks for your help.
amtrac24 is offline   Reply With Quote
Old November 14th, 2004, 01:48 PM     #4 (permalink)
Member
 
Join Date: Oct 2003
Posts: 263
i think i got it.

OleDbDataAdapter1.SelectCommand.CommandText = _
"SELECT user_name, user_password " & _
"FROM users where user_name='" & username & "';"

DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)

Dim i As String

i = DataSet11.Tables("users").Rows(i).Item("user_name" )
MsgBox(i)

Thanks for your help. It works
amtrac24 is offline   Reply With Quote
Old November 14th, 2004, 02:22 PM     #5 (permalink)
Member
 
Join Date: Sep 2002
Posts: 364
That's basically the decision you have to make. There are so many ways to get data. If you are just looking to get the one row, then I wouldn't go with a DataSet. Here is the breakdown:

1. If you need to maintain multiple tables of data, use a DataSet
2. If you need to maintain just one table, and are interested in more than one row, use a DataTable.
3. If you don't need to maintain any data and dont need to save the actual data (which looks like what you are doing), use a DataReader.
4. If you just need ONE column's value, use just the one column in your SELECT statement, and use the .ExecuteScalar() method of your command.

Alternatively, if you need just one row of data, but many columns, use output parameters if your database supports stored procedures. This way, you just execute the command and check its parameters.
Creosote is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
can I mask portions of a word document? rande Applications and Operating Systems 2 April 23rd, 2004 10:29 AM
PHP Radio Button Email Help, Verify Password embj Webmastering and Programming 13 July 12th, 2003 10:44 PM
Computer emmits high pitch noise - ideas? newbie~wan General Tech Discussion 14 April 26th, 2002 02:32 PM
Linux | question SpookyEddy Applications and Operating Systems 4 March 16th, 2002 06:00 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Making Health Care Worse (174)
Is It Just Me? (2938)
The disrespect of Obama by Russian .. (23)
Wireless Televisions. (12)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Regular Build (6)
Is the PSU I received dead? (12)
radeon x850xt platinum & shader.. (5)
Print spooler problem (15)
HIS HD5770 graphic card question (15)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Recent Discussions
For Sale BFG GTX285 OC2 with 10 year .. (3)
Point and Shoot Camera Suggestions. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Graphics Card Upgrade Question (3)
Laptop with wireless problem. (2)
Internet Lost (1)
Hp Artist Edition + Matching Bag (0)
My monitor won't turn on after instal.. (0)
Asus P4G8X Mobo (6)
radeon x850xt platinum & shader 3 (5)
Xbox 360 GTA: SA disk error (1)
Is the PSU I received dead? (12)
windows 7 internet problem (5)
Multiple Restarts Required at Boot (0)
BSOD On Startup (ntoskrnl.exe) (2)
Print spooler problem (15)
Have you switched yet? (86)
screen resolution vs monitor size (2)
sms storage to PC (0)
Regular Build (6)
Open With ..... Win7 (0)
java code for fibonacci (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (35)
windows 7 problem (7)


All times are GMT -4. The time now is 09:40 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28