0
  1. Hi, i met this error in asp.net. I was trying to make a login page, which enable user choose admin or user in radiobuttonlist. If admin login, he will go to admin page. It will check the admin name and password which is built in database.I use the same method for user. User already sign up, his name and password already put inside database. User login will go to user page. But when i want to check whether user name and password in database, i get syntax error. Here is the error

  2. Here is the code for button click login.

    Protected Sub loginButton_Click(sender As Object, e As EventArgs)    Handles loginButton.Click
      Dim na As String
      Dim pa As String
      Dim dv As DataView
      Dim rs As Integer
    
      na = username.Text
      pa = password.Text
    
      If RadioButtonList1.SelectedValue = "Administrator" Then
    
        SqlDataSource1.SelectCommand = "select * from admin where name = '" & na & "' and password = '" & pa & "'"
        dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
    
        If dv.Count = 1 Then
            Response.Redirect("HomeAdmin.aspx")
         Else
            Label8.Text = "Invalid admin name or password, Please key in again !"
        End If
    Else
        SqlDataSource2.SelectCommand = "select * from user where name = '" & na & "' and password = '" & pa & "'"
        dv = CType(SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView)
    
        If dv.Count = 1 Then
            Response.Redirect("HomeUser.aspx")
        Else
            Label8.Text = "Invalid user name or password, Please key in again !"
        End If
    End If
    
  3. Here is my login page. Login page

  4. I have no problem when i login with admin, but got error when login with user. Thanks for Help!

5
  • Can you specify the exact error? Commented Nov 22, 2015 at 4:20
  • I can choose radiobutton between user and admin. But i cannot get the userdata from the database to login into the page.However, i can get the admin data from database and login in with admin. I use the same coding concept with admin to apply on user. I duno what is the error means for me. Commented Nov 22, 2015 at 4:25
  • You need to provide more detail regarding the error. Code you posted has no issues. Check the SqlDataSource2 connection string may be that is causing the issue. Commented Nov 22, 2015 at 4:44
  • the sqldatasource2 is connect to user table. user table consist of three data which are name,email,password.That is for storing user name,email and password in database. And my select statement is select * from user. However, user just have to enter name and password to login. Commented Nov 22, 2015 at 4:50
  • I also try select name and password from user. But the error still come out. I have no idea on this. Changing select statement in the connection string. Commented Nov 22, 2015 at 4:51

2 Answers 2

1

why do you use two sqldatasources? you need just one. Use one sqldatasource.

Sign up to request clarification or add additional context in comments.

1 Comment

one sqldatasources for user, one sqldatasources for admin. If choose admin, go inside admin sqldatasources. There are 2 table, so i use two sqldatasources..If use one sqldatasources, can i select useror admin?
0

You can't bind two Datasource in a control. Please share your error details please.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.