1

Heya guys, this is my first post - this forum has been loads of help in the past :)

Anyway, I am currently coding a program that requests a user's Log In name and password, and then (via a SQL query) checks it against a record in the database, and returns the Member Number. The only thing is that I'm not sure how to return the Member Number into a variable. Here's what I have so far:

sqlcon.Open()
Dim username As String = UsernameTextbox.Text
Dim password As String = PasswordTextbox.Text
Dim memnumber as integer
Dim DataCommand As New SqlCeCommand

DataCommand = sqlcon.CreateCommand
DataCommand.CommandText = "SELECT MemberNumber FROM MembersProgramDetails WHERE Username =" & username & "AND Password =" & password
'RETURN VALUE OF MEMBER NUMBER TO (memnumber)

Any help is greatly appreciated,
Ryan.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rmontgomery
1
DataCommand.CommandText = "SELECT MemberNumber FROM MembersProgramDetails WHERE Username='" & username & "' AND Password='" & password & "'"
0

Thanks adatapost, got it sorted using your help, and the SqlDataReader, here's the code if anyone is interested:

sqlcon.Open() ' globally declared connection
Dim username As String = UsernameTextbox.Text
Dim password As String = PasswordTextbox.Text
Dim memnumber as integer
Dim DataCommand As New SqlCeCommand
 
DataCommand = sqlcon.CreateCommand
DataCommand.CommandText = "SELECT MemberNumber FROM MembersProgramDetails WHERE Username ='" & username & "'AND Password ='" & password & "'"

Dim DataReader as SqlCeDataReader = DataCommand.ExecuteReader()
While DataReader.read
memnumber = (DataReader(0))       ' the 0 means to return the first value of what the data reader has returned
End While
DataReader.close
sqlcon.close

Edited by rmontgomery: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.