unable to search Text only Integers

G

Guest

I have the following in ASP, and it works fine unless I change the SELECT ID
field to something else that isn't an integer. In other words, if I change
ID to city it doesn't work, and the only connection I can make is that my
bind only accepts integers, can someone help me?

Dim dstProducts As DataSet
Dim dadProducts As SqlDataAdapter
Label1.Visible = False

dstProducts = New DataSet()

Dim conPubs as SqlConnection

conPubs = New
SqlConnection("Server=LENVSQL;uid=itam;pwd=agenda;database=Discovery")

conPubs.Open()

dadProducts = New SqlDataAdapter( "SELECT ComputerName, IPAddress,
SerialNo FROM Computer WHERE ID = " & TextBox1.Text, conPubs)

Try

dadProducts.Fill( dstProducts, "Computer") 'the error occurs here
if ID is changed to City

dgEmployee.DataSource = dstProducts
dgEmployee.DataBind()
dgEmployee.Visible = True
 
G

Guest

I tried the following, it still does not pick up the values.

dadProducts = New SqlDataAdapter( "SELECT ComputerName, IPAddress,
SerialNo FROM Computer WHERE 'IPAddress'=" & TextBox1.Text, conPubs)

And I have also tried:
dadProducts = New SqlDataAdapter( "SELECT ComputerName, IPAddress,
SerialNo FROM Computer WHERE 'IPAddress'=" & TextBox1.Text.ToString(),
conPubs)

It still does not pull data, can you give me an example?
 
G

Guest

the following takes care of it.

dadProducts = New SqlDataAdapter( "SELECT ComputerName, IPAddress,
SerialNo FROM Computer WHERE IPAddress =" & "'" & TextBox1.Text & "'",
conPubs)
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top