Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2006-02-01 : 12:25:49
|
hello forum,I need to grab a string value from a list box in from a web form, and pass it to a sql select command statement where that value is equal toall values in a database table(sql 2000).example zip code list box3315433254 845788547535454 selected value is 85475I am putting that value in a string like this:dim string_zip as stringstring_zip = zip_ListBox.textQuestion, how do i pass that value to sql stament, i am using this but does not work.SqlCommand1 = New SqlCommand("SELECT zip FROM table WHERE zip = string_zip", SqlConnection1) |
|
jhermiz
3564 Posts |
Posted - 2006-02-02 : 14:38:56
|
quote: Originally posted by alxtech hello forum,I need to grab a string value from a list box in from a web form, and pass it to a sql select command statement where that value is equal toall values in a database table(sql 2000).example zip code list box3315433254 845788547535454 selected value is 85475I am putting that value in a string like this:dim string_zip as stringstring_zip = zip_ListBox.textQuestion, how do i pass that value to sql stament, i am using this but does not work.SqlCommand1 = New SqlCommand("SELECT zip FROM table WHERE zip = string_zip", SqlConnection1)
You should be using stored procedures, dynamic sql is a no no.Anyhow:strSQL = "SELECT zip FROM myTable WHERE zip= '" & MyTextbox.Text & "'"SQLCommand1= New SQLCommand(strSQL, SQLConnection1) Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url] |
 |
|
|
|
|