naresh_kalyan
New member
- Joined
- Sep 6, 2010
- Messages
- 1
- Programming Experience
- Beginner
Dear All,
I know vb.net little bit. Now, I'm creating a New Website by using mySQL as Dbase. Here, just I need to get a simple LOGIN page thru aspx.vb. I created Table in SQL which is having only username and password. Please, find the code snippet, I created by searching here and there in all search Engines. But, some thing wrong in this code. it is giving error "Incorrect syntax near '='."
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim connString As String
connString = "server=hst-pcs-20798;" & _
"database=ParkerTest;uid=sa;password=satyam123$"
Dim sql As String = _
"select count(*) from user_master where username='@user' & password='@pass'"
Using conn As New Data.SqlClient.SqlConnection(connString)
Dim cmd As New Data.SqlClient.SqlCommand(sql, conn)
cmd.Parameters.Add("@user", Data.SqlDbType.VarChar)
cmd.Parameters("@user").Value = TextBox1.Text
cmd.Parameters.Add("@pass", Data.SqlDbType.VarChar)
cmd.Parameters("@pass").Value = TextBox2.Text
Try
conn.Open()
Dim count As Integer
count = Convert.ToInt32(cmd.ExecuteScalar())
' Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
If count = 0 Then
'Label3.Text = "invalid entry"
MsgBox("invalid entry")
ElseIf count = 1 Then
Label3.Text = "correct entry"
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
Thanks in advance....
I know vb.net little bit. Now, I'm creating a New Website by using mySQL as Dbase. Here, just I need to get a simple LOGIN page thru aspx.vb. I created Table in SQL which is having only username and password. Please, find the code snippet, I created by searching here and there in all search Engines. But, some thing wrong in this code. it is giving error "Incorrect syntax near '='."
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim connString As String
connString = "server=hst-pcs-20798;" & _
"database=ParkerTest;uid=sa;password=satyam123$"
Dim sql As String = _
"select count(*) from user_master where username='@user' & password='@pass'"
Using conn As New Data.SqlClient.SqlConnection(connString)
Dim cmd As New Data.SqlClient.SqlCommand(sql, conn)
cmd.Parameters.Add("@user", Data.SqlDbType.VarChar)
cmd.Parameters("@user").Value = TextBox1.Text
cmd.Parameters.Add("@pass", Data.SqlDbType.VarChar)
cmd.Parameters("@pass").Value = TextBox2.Text
Try
conn.Open()
Dim count As Integer
count = Convert.ToInt32(cmd.ExecuteScalar())
' Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
If count = 0 Then
'Label3.Text = "invalid entry"
MsgBox("invalid entry")
ElseIf count = 1 Then
Label3.Text = "correct entry"
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
Thanks in advance....
Last edited: