Wednesday, March 7, 2012

Newbie:Why this Select doesn't work ?

On ASP.NET 2.0, VB, I try to let user input data on TxtBox1.Text. Then I
would like to go to SQL database named PUBS and compare the "TxtBox1.Text"
against the table "job_id". If the results match, I return on the screen
"Information matched. Your password will be reset".
First, how can I establish the connection to the "pubs" and retrieve such
information ? The code below return error "job_id" not declared. Do I really
have to declare the "job_id" or something else I did is not working ?
rtial Class Default_aspx
Sub btnDefault_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sConnect As String = ConfigurationSettings.ConnectionStrings_
("pubs").ConnectionString
Dim sSQL As String = "SELECT Employee, " _
& "WHERE job_id = TxtBox1.Text"
End Sub
End Class> Dim sSQL As String = "SELECT Employee, " _
> & "WHERE job_id = TxtBox1.Text"
Your query string should be "Select * from Employee where job_id = '" &
TxtBox1.Text & "'"
"Mr. Magoo" <maggo@.nospasm.com> wrote in message
news:ub3B3mUJFHA.1176@.TK2MSFTNGP12.phx.gbl...
> On ASP.NET 2.0, VB, I try to let user input data on TxtBox1.Text. Then I
> would like to go to SQL database named PUBS and compare the
> "TxtBox1.Text" against the table "job_id". If the results match, I return
> on the screen "Information matched. Your password will be reset".
> First, how can I establish the connection to the "pubs" and retrieve such
> information ? The code below return error "job_id" not declared. Do I
> really have to declare the "job_id" or something else I did is not working
> ?
> rtial Class Default_aspx
> Sub btnDefault_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Dim sConnect As String = ConfigurationSettings.ConnectionStrings_
> ("pubs").ConnectionString
> Dim sSQL As String = "SELECT Employee, " _
> & "WHERE job_id = TxtBox1.Text"
> End Sub
> End Class
>|||There is no From clause in this select statement. You need to specify that.
Dim sSQL As String = "SELECT Employee From Pubs " _
& "WHERE job_id = " & TxtBox1.Text
Thanks
Baiju
"Mr. Magoo" <maggo@.nospasm.com> wrote in message
news:ub3B3mUJFHA.1176@.TK2MSFTNGP12.phx.gbl...
> On ASP.NET 2.0, VB, I try to let user input data on TxtBox1.Text. Then I
> would like to go to SQL database named PUBS and compare the
"TxtBox1.Text"
> against the table "job_id". If the results match, I return on the screen
> "Information matched. Your password will be reset".
> First, how can I establish the connection to the "pubs" and retrieve such
> information ? The code below return error "job_id" not declared. Do I
really
> have to declare the "job_id" or something else I did is not working ?
> rtial Class Default_aspx
> Sub btnDefault_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Dim sConnect As String = ConfigurationSettings.ConnectionStrings_
> ("pubs").ConnectionString
> Dim sSQL As String = "SELECT Employee, " _
> & "WHERE job_id = TxtBox1.Text"
> End Sub
> End Class
>|||You guys are rocking !!
"Baiju" <baiju@.indus-systems.com> wrote in message
news:eBE94EVJFHA.2640@.TK2MSFTNGP09.phx.gbl...
> There is no From clause in this select statement. You need to specify
> that.
> Dim sSQL As String = "SELECT Employee From Pubs " _
> & "WHERE job_id = " & TxtBox1.Text
> Thanks
> Baiju
> "Mr. Magoo" <maggo@.nospasm.com> wrote in message
> news:ub3B3mUJFHA.1176@.TK2MSFTNGP12.phx.gbl...
> "TxtBox1.Text"
> really
>

No comments:

Post a Comment