hello,
I am trying to get a login form working in Visual Basic Express 2008.
Using WinForms, i have the following code.
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = "Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MTS.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True"
conn.Open()
MessageBox.Show("Database connection open")
Dim sql = "SELECT * FROM Users WHERE Users.username = " &
Me.UsernameTextBox.Text & _
" AND Users.password = " & Me.PasswordTextBox.Text
MessageBox.Show(sql)
Dim da As SqlClient.SqlDataAdapter
da = New SqlClient.SqlDataAdapter(sql, conn)
Dim ds As New DataSet
da.Fill(ds, "Users")
If ds.Tables("Users").Rows(0).Item(2) =
Me.UsernameTextBox.Text Then
If ds.Tables("Users").Rows(0).Item(3) =
Me.PasswordTextBox.Text Then
MessageBox.Show("Login Successfull")
Dim role As String
role = ds.Tables("Users").Rows(0).Item(4).ToString
My.User.IsInRole(role)
MTS.Main_Window.Show()
Me.Close()
End If
Else
MessageBox.Show("Username does not exist. Please check
the spelling and try again." _
, "MTS Information", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End If
conn.Close()
Getting an error stating ("invalid column names") at da.Fill(ds,
"Users")
any ideas what i'm doing wrong?