Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Login Button - Not working

Posted on 2013-06-11
11
Medium Priority
?
281 Views
Last Modified: 2013-06-17
Can anyone tell me where I am going wrong with my login button?


Protected Sub txtLoginBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles txtLoginBtn.Click
        Dim usersadapter As New usersdataset.tbl_otuserstableadapter()
        Dim tbl_otusers As UsersDataSet.tbl_otusersDatatable

        Try
            Dim strUserId As String = txtUserId.Text
            Dim strpwd As String = txtPwd.Text

            Dim numrecords As Int16 = tBL_OTUSERSTableAdapter.FillbyLogin(Me.usersdataset.tbl_otusers, strUserId, strpwd)
            If (numrecords > 0) Then
                Dim dbuserid As String = Me.UsersDataset.tbl_otusers(0).username
                Dim dbpwd As String = Me.usersdataset.tbl_otusers(0).password
                If dbuserid.Equals(strUserId) And dbpwd.Equals(strpwd) Then
                    'user is authenticated
                    Dim mainfrm As New Monthly_OTExc70
                    mainfrm.userid = dbuserid
                    mainfrm.show()
                    Me.close()
                    Return

                Else
                    messagebox.show("Incorrect userid and password. Please try again!")
                    Return
                End If
                messagebox.show("Incorrect userid and password. Please try again!")
            End If


        Catch ex As Exception
            messagebox.show(ex.Message)
            Return
        End Try
    End Sub
0
Comment
Question by:ernie_shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
11 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39238201
Whats the error?
0
 

Author Comment

by:ernie_shah
ID: 39238587
The code is not being built successfully.

The following lines are underlined...

Dim usersadapter As New usersdataset.tbl_otuserstableadapter()
Dim tbl_otusers As UsersDataSet.tbl_otusersDatatable
Dim dbuserid As String = Me.UsersDataset.tbl_otusers(0).username
Dim dbpwd As String = Me.usersdataset.tbl_otusers(0).password
Dim mainfrm
mainfrm.userid = dbuserid
mainfrm.show()
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39238792
Do you have a typed dataset named UsersDataset in your project?

I would change your code to following (Change SQLConnection and SQLCommand to equivalent oracle objects)

Protected Sub txtLoginBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles txtLoginBtn.Click
        Try
           Dim dbcon as New SqlConnection("your connection string")
           dbcon.Open
           Dim dbcmd as New SqlCommand
           dbcmd.Connection = dbcon
           dbcmd.CommandText = "Select IsNull(Count(*), 0) From Users Where Username=@Username AND Password=@Password"
           dbcmd.Parameters.AddWithValue("@Username", strUserId)
           dbcmd.Parameters.AddWithValue("@Password", txtPwd.Text)
           Dim Count As Integer = dbcmd.ExecuteScalar()
           dbcmd.Dispose
           dbcon.Dispose
           If (Count > 0) Then
                    'user is authenticated
                    Dim mainfrm As New Monthly_OTExc70
                    mainfrm.userid = dbuserid
                    mainfrm.show()
                    Me.close()             
            Else
                    messagebox.show("Incorrect userid and password. Please try again!")
                    Return
            End If
                messagebox.show("Incorrect userid and password. Please try again!")
            End If
        Catch ex As Exception
            messagebox.show(ex.Message)
            Return
        End Try
    End Sub

Open in new window

0
URL rewriting in AWS CloudFront

A quick how-to guide to implement with a Lambda function!

 

Author Comment

by:ernie_shah
ID: 39239080
The following runs without any build error but when I click on the button the attached error is thrown.


Protected Sub txtLoginBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles txtLoginBtn.Click
        Try
            Dim dbcon As New SqlConnection("Data Source=mydb;Persist Security Info=True;User ID=myuserid;Password=mypwd")
            dbcon.Open()
            Dim strUserId As String = txtUserId.Text
            Dim strpwd As String = txtPwd.Text
            Dim dbcmd As New SqlCommand
            dbcmd.Connection = dbcon
            dbcmd.CommandText = "Select IsNull(Count(*), 0) From Users Where Username=@Username AND Password=@Password"
            dbcmd.Parameters.AddWithValue("@Username", strUserId)
            dbcmd.Parameters.AddWithValue("@Password", txtPwd.Text)
            Dim Count As Integer = dbcmd.ExecuteScalar()
            dbcmd.Dispose()
            dbcon.Dispose()
            If (Count > 0) Then
                Response.Redirect("~monthly.aspx")
            Else
                MsgBox("Incorrect userid and password. Please try again!")
                Return
            End If
            'MsgBox("Incorrect userid and password. Please try again!")

        Catch ex As Exception
            MsgBox(ex.Message)
            Return
        End Try

    End Sub
error.docx
0
 

Author Comment

by:ernie_shah
ID: 39239117
What  test can I perform to open a connection and read data from an oracle table?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1000 total points
ID: 39239385
Yes the issue is with your connection string. Do you have SQL tool that comes with Oracle?

This would be useful as well

http://www.connectionstrings.com/oracle
0
 

Author Comment

by:ernie_shah
ID: 39241077
I don't have any sql tools. I have sql worksheet and sql plus that comes with oracle.

Should I download a free sql tool? Would that assist with connection and sql coding with asp.net?
0
 

Author Comment

by:ernie_shah
ID: 39241078
Thanks for the link
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39242397
I was referring to SQL Plus. Have you tried connecting to Oracle using SQL Plus?
0
 

Author Comment

by:ernie_shah
ID: 39253837
I am able to connect with sql plus
0
 

Author Comment

by:ernie_shah
ID: 39253850
Would oracle version be an issue? I have both Orale 9i and 10g installed on my computer
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question