Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERT help needed 1

Status
Not open for further replies.

AppzDev

MIS
Oct 9, 2002
57
US
Scenario: User picks an employee from a listbox and clicks a button that edit's some values in another page. On the btnEdit_OnClick a datareader fires off to check to see if that person has any values and if they don't returns a label stating that "there are no values to edit". Well, it worked fine until i imported some new data in which some of the empID's have an alpha character in them. The SQL database has empID as a varchar so i assume there is a conversion taking place on the page.

Here is a snippet of what the code looks like.

Select * from EmpTable where emp_id = " & listbox1.selecteditem.value

Dim myReader etc...

The error i get is "Invalid column name 'R50792769'" where the R5... is the empid.

Another quick question is...is there some property that i may be missing that allows like an autocomplete on lsitboxes so when i type let's say "smi" in the listbox it brings me to smith etc.

Thanks for any help. This forum has been my savior more than once.

dc~
 
Try this:

Select * from EmpTable where emp_id = '" & listbox1.selecteditem.value & "'"

Notice the single Quotes....

-Gary

 
Gary,

my friend, i owe you a beer! That worked fantastic. I am relatively new to ASP.NET and my syntax skills, simply put, suck. I am learning new little tricks here and there though.

Speaking of...anyone have some resources on ASP.NET syntax? and/or examples?

Thanks again Gary!!

dc~
 
Just a note that pertains to your question. Using straight strings to build queries actually poses a security risk. We had an entire thread dedicated to this a while back. It is really a good read, I took a lot away from it myself.

Thread855-379869 enjoy

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top