Click here to Skip to main content
15,890,123 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionWHERE WILL I GET VB.NET PROJECT Pin
rahuldsac21-Jan-10 6:04
rahuldsac21-Jan-10 6:04 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
Dave Kreskowiak21-Jan-10 6:43
mveDave Kreskowiak21-Jan-10 6:43 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
Steven J Jowett21-Jan-10 7:00
Steven J Jowett21-Jan-10 7:00 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
JHizzle21-Jan-10 7:57
JHizzle21-Jan-10 7:57 
JokeRe: WHERE WILL I GET VB.NET PROJECT Pin
Gagan.2022-Jan-10 1:54
Gagan.2022-Jan-10 1:54 
AnswerRe: WHERE WILL I GET VB.NET PROJECT Pin
darkelv22-Jan-10 2:10
darkelv22-Jan-10 2:10 
GeneralRe: WHERE WILL I GET VB.NET PROJECT Pin
Smithers-Jones22-Jan-10 3:51
Smithers-Jones22-Jan-10 3:51 
Questiondatareader error how to solve Pin
Patrício dos Santos21-Jan-10 5:07
Patrício dos Santos21-Jan-10 5:07 
Hi every one...

I have a Windows Form Application in VB.Net... in this Windows Form I have a textBox... with a "validate" button...

I need that when I input a user ID in the text box, the application go to the access and user table to see if the user is admin... if true print user name is admin else prints user name is not admin

the 2 tables design

tblUser (IDUser, UserName, FullName)
tblAcess (IDUser, AccessLevel [that can be admin or user] )

I just try to do it, but I receaved a message that the datareader is allready open and I cannot open other datareader.... see my code please:

<br />
Private Sub txtCardNum_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCardNum.KeyPress<br />
        If Char.IsNumber(e.KeyChar) Or e.KeyChar = Chr(13) Or e.KeyChar = Chr(8) Then<br />
            e.Handled = False<br />
            If e.KeyChar = Chr(13) Then<br />
                If txtCardNum.Text = "" Then<br />
                    MsgBox("User ID can not be empty")<br />
                Else<br />
                    Dim CardNum As String = txtCardNum.Text<br />
                    <br />
                    Dim SQL As String<br />
                    SQL = "SELECT U.CodUser, U.FullName FROM tblUser U INNER JOIN tblAccess A ON U.CodUser = A.CodUser WHERE A.AccessLevel = 'Admin' AND A.CodUser = @CodUser"<br />
                    Dim myCommand = New SqlCommand(SQL, myConnection)<br />
                    myCommand.Parameters.Add("@CodUser", SqlDbType.VarChar).Value = CardNum<br />
<br />
                    Dim SQL2 As String<br />
                    SQL2 = "SELECT CodUser, FullName FROM tblUser WHERE CodUser = @CodUser"<br />
                    Dim myCommand2 = New SqlCommand(SQL2, myConnection)<br />
                    myCommand2.Parameters.Add("@CodUser", SqlDbType.VarChar).Value = CardNum<br />
<br />
                    Dim reader As SqlDataReader = myCommand.ExecuteReader()<br />
                    Dim reader2 As SqlDataReader = myCommand2.ExecuteReader()<br />
                    'Caso existam linhas<br />
                    If reader.HasRows Then<br />
                        While reader.Read()<br />
                            lblFullName.Text = reader(1)<br />
                            lblLevel.Text = "Admin" <br />
                            txtCardNum.Text = ""                        <br />
                        End While<br />
                        reader.Close()<br />
                    Else<br />
                        Dim reader2 As SqlDataReader = myCommand2.ExecuteReader()<br />
                        lblNomeCliente.Text = reader2(1)<br />
                        lblLevel.Text = "Normal User"<br />
                        txtCardNum.Text = ""<br />
                        reader2.Close()<br />
                    End If<br />
                End If<br />
            End If<br />
        Else<br />
            e.Handled = True<br />
        End If<br />
<br />
    End Sub<br />
<br />


but when I try to execute and do the query I receave a error: "the data reader is allready open"

how can I solve it?

thanks

regards
PS
AnswerRe: datareader error how to solve Pin
Dave Kreskowiak21-Jan-10 5:19
mveDave Kreskowiak21-Jan-10 5:19 
GeneralRe: datareader error how to solve Pin
Patrício dos Santos21-Jan-10 5:41
Patrício dos Santos21-Jan-10 5:41 
GeneralRe: datareader error how to solve Pin
Dave Kreskowiak21-Jan-10 6:45
mveDave Kreskowiak21-Jan-10 6:45 
GeneralRe: datareader error how to solve Pin
Patrício dos Santos21-Jan-10 8:45
Patrício dos Santos21-Jan-10 8:45 
GeneralRe: datareader error how to solve Pin
Dave Kreskowiak21-Jan-10 9:37
mveDave Kreskowiak21-Jan-10 9:37 
GeneralRe: datareader error how to solve Pin
Patrício dos Santos21-Jan-10 10:09
Patrício dos Santos21-Jan-10 10:09 
GeneralRe: datareader error how to solve Pin
Dave Kreskowiak21-Jan-10 10:33
mveDave Kreskowiak21-Jan-10 10:33 
Question.dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
Mr Oizo20-Jan-10 22:37
Mr Oizo20-Jan-10 22:37 
AnswerRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
DaveAuld21-Jan-10 2:25
professionalDaveAuld21-Jan-10 2:25 
GeneralRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
Mr Oizo21-Jan-10 21:05
Mr Oizo21-Jan-10 21:05 
GeneralRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
DaveAuld21-Jan-10 21:15
professionalDaveAuld21-Jan-10 21:15 
GeneralRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
Mr Oizo24-Jan-10 23:09
Mr Oizo24-Jan-10 23:09 
GeneralRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
DaveAuld25-Jan-10 0:34
professionalDaveAuld25-Jan-10 0:34 
GeneralRe: .dat fixed length files being compressed when e-mailed to recipient through vb.net (URGENT!!!) Pin
Mr Oizo25-Jan-10 3:13
Mr Oizo25-Jan-10 3:13 
QuestionHow to seperate Letters, Numbers from a string? Pin
Paramu197320-Jan-10 22:12
Paramu197320-Jan-10 22:12 
AnswerRe: How to seperate Letters, Numbers from a string? Pin
Wayne Gaylard20-Jan-10 22:27
professionalWayne Gaylard20-Jan-10 22:27 
GeneralRe: How to seperate Letters, Numbers from a string? Pin
Paramu197320-Jan-10 22:35
Paramu197320-Jan-10 22:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.