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:40:15
|
| 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) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-01 : 12:42:26
|
| SqlCommand1 = New SqlCommand("SELECT zip FROM table WHERE zip = " & string_zip, SqlConnection1)Tara Kizeraka tduggan |
 |
|
|
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2006-02-01 : 12:55:45
|
| Thanks Brother, another question,what if multiple values are selected in form, and then pass to query. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-01 : 13:02:07
|
| It would be sister.You would need to use zip IN (Value1, Value2, ...)Tara Kizeraka tduggan |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-02 : 09:07:32
|
Something likestring_zip=""for i=1 to zip_ListBox.count if zip_ListBox.selected=true then string_zip=string_zip & "," & zip_ListBox.Textnext istring_zip=mid(string_zip,2,len(string_zip)SqlCommand1 = New SqlCommand("SELECT zip FROM table WHERE zip in (" & string_zip & ")", SqlConnection1)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|