Click here to Skip to main content
15,937,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need get address to lable when I enter name into textbox. My code is like this
da=new sqldataadapter("SELECT * FROM members WHERE name=" & textbox1.text &"", dbconn)
catch ex as exception
exit sub
end try

sub bind()
end sub

Unfortunately its not working. Otherwise I can't see eny errors.

Then i try search infomation by there age. its worked. but I have no idea to get address when emter there names.
im using and sql server.
Updated 3-Feb-12 5:36am

Couple of things!

1. Look at parameterised Queries it will protect you against SQL Injection

Read / Example : SQL Parameterised query example[^]

2. you have a Try Catch block, but you just exit the sub! as others have stated you need to, if any errors are trapped do something with the error.

3. Have a try of this

 dim dt as Datatable = ds.table(0)
 dim dr as Datarow = dt.rows(0)

'I have assumed that the values you are after are in column 1, it is considered better practice to replace the ordinal number with its name
 Label1.text = dr(0).toString()
Share this answer
Put the code and you will see the error ;)
catch ex as exception
end try
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900