VB.NET / Database question
-
in my code
Private Sub logonBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logonBtn.Click 'Validate logon username and password. Dim myresult As Integer myresult = Me.TeacherTableAdapter.usernamePassword(PasswordTextBox.Text, UsernameTextBox.Text) If myresult = 0 Then MessageBox.Show("Logon Error; Username or Password is incorrect") Exit Sub End If MessageBox.Show("Welcome to Teachers Pet") Call LoadMainScreen() End Sub
What if I wanted to return back more than one item...for instance, right now it's returning the user ID, what if I wanted, userID, TGrade, FullName? Would I just return everything back in an array? Thanks.....and if this is the wrong board and should be on the ADO.NET then let me know and I'll delete this and move it there.Tom Wright tawright915@gmail.com
-
in my code
Private Sub logonBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logonBtn.Click 'Validate logon username and password. Dim myresult As Integer myresult = Me.TeacherTableAdapter.usernamePassword(PasswordTextBox.Text, UsernameTextBox.Text) If myresult = 0 Then MessageBox.Show("Logon Error; Username or Password is incorrect") Exit Sub End If MessageBox.Show("Welcome to Teachers Pet") Call LoadMainScreen() End Sub
What if I wanted to return back more than one item...for instance, right now it's returning the user ID, what if I wanted, userID, TGrade, FullName? Would I just return everything back in an array? Thanks.....and if this is the wrong board and should be on the ADO.NET then let me know and I'll delete this and move it there.Tom Wright tawright915@gmail.com
Hi Tom, By the look of it I think it might actually be reasonably easy (but no guarantees):
Private Sub logonBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logonBtn.Click 'Validate logon username and password. Dim myresult() As String myresult = Me.TeacherTableAdapter.usernamePassword(PasswordTextBox.Text, UsernameTextBox.Text) If myresult.GetValue(0) = 0 Then MessageBox.Show("Logon Error; Username or Password is incorrect") Exit Sub End If MessageBox.Show("Welcome to Teachers Pet") Call LoadMainScreen() End Sub
Tom Wright wrote:
userID, TGrade, FullName
It looks like you want to return data of different types, so the array would best be made of type String. You can then use the data from the myresult array with
.GetValue(0-based index number here)
and convert values from the string type to integer, etc. where needed. As I don't know the code on theMe.TeacherTableAdapter.usernamePassword(PasswordTextBox.Text, UsernameTextBox.Text)
side, your on your own making it return multiple values. Hope this helps, JohanMy advice is free, and you may get what you paid for.
-
in my code
Private Sub logonBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logonBtn.Click 'Validate logon username and password. Dim myresult As Integer myresult = Me.TeacherTableAdapter.usernamePassword(PasswordTextBox.Text, UsernameTextBox.Text) If myresult = 0 Then MessageBox.Show("Logon Error; Username or Password is incorrect") Exit Sub End If MessageBox.Show("Welcome to Teachers Pet") Call LoadMainScreen() End Sub
What if I wanted to return back more than one item...for instance, right now it's returning the user ID, what if I wanted, userID, TGrade, FullName? Would I just return everything back in an array? Thanks.....and if this is the wrong board and should be on the ADO.NET then let me know and I'll delete this and move it there.Tom Wright tawright915@gmail.com
Looks like you're using some tool to generate the Datalayer. If this is true, just change the underlying SP that is executed by Me.TeacherTableAdapter.usernamePassword() function to return a resultset instead of just a string output. And run the tool again. This will make the function return a DataRow of the underlying table. If the above is not true, you've to start from the ground up. Modify the SP to return a resultset, modify the function to read the resultset using a DataReader or a DataSet. SG