Help with using a Text Box to pass parameters to SQL

J

Jeff Thur

I need help with the following:
I am doing a lookup screen for users.
I am accessing a SQL Query.
The User can enter either a State or the first 6
characters of the first name and the first name initial.
Passing a parameter of the State code is not a problem,
as I can do it with a Drop Down box and use
SelectedValue. However I need the user to be able to
enter the first 6 characters of the last name and the
first intial of the first name into a Text type Box. I
tried to use a Text Box Control for this but as I found
out, the Text Box doesn't Support the SelectedValue so
this won't cut it for me. I am not sure how to use the
textbox for passing parameters.


Any ideas as to how I would go
about this would be welcomed. Thank You for any help that
you can provide.
.


...


..
 
G

Guest

-----Original Message-----
I need help with the following: the
textbox for passing parameters.


Any ideas as to how I would go


...


..

I Know a TextBox.Text will do it, However I need the
Flow, This is my Test Program but it doesn't work.

Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = dbCommand.ExecuteReader()
DataGrid1.DataBind()
End Sub



Sub Page_Load(sender As Object, e As EventArgs)

Dim sParam As String = TxtLast.Text
Dim sSQL As String = "Select Col099, Col008, Col017,
Col018 From Jeff Where Col099 = @Col099"
Dim connectionString As String = "server='(local)'; user
id='sa'; password='fritz'; database='Cutis'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
Try
dbcommand.Parameters.Add ("@Col099")
dbCommand.CommandType = (sSQL)
dbConnection.Open()
dbConnection.Close()
Catch dbError As Exception
dbConnection.Close()
End Try



End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top