syntax error in query expression in vb.net

A

amitbadgi

I am geting the following error while conv an asp to asp.net
Exception Details: System.Runtime.InteropServices.COMException: Syntax
error in query expression 'id =System.__ComObject'.

Source Error:

Line 196: for i = 0 to ubound(emaillist)
Line 197: selectsqlstatement = "select * from tblusers where id =" &
emaillist(i)

Line 198: rs_email = conn.execute(selectsqlstatement)
Line 199: tolist = tolist & rs_email("email") & ";"
Line 200:


Source File: C:\Documents and Settings\amit\WebSite1\email_form.aspx
Line: 198

Stack Trace:

[COMException (0x80040e14): Syntax error in query expression 'id
=System.__ComObject'.]
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,
Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack) +965
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) +193727
ASP.email_form_aspx.__Render__control1(HtmlTextWriter __w, Control
parameterContainer) in C:\Documents and
Settings\amit\WebSite1\email_form.aspx:198
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24

The code for teh foll is,

<%
Dim counter,rs_email, tolist
Dim emaillist as string()
dim i as integer
emaillist = split(request.Form("c"), ",")
counter = 1
dim selectSqlStatement as string
for i = 0 to ubound(emaillist)
selectsqlstatement = "select * from tblusers where id =" &
emaillist(i)
rs_email = conn.execute(selectsqlstatement)
tolist = tolist & rs_email("email") & ";"

response.Write(rs_email("email")&";")

if counter = 3 then
response.Write("<br>")
counter = 1
end if

counter = counter + 1
next
%>
 
N

Nick Malik [Microsoft]

three syntax errors in a row... Impressive.
clearly, the value of the expression emaillist(i) isn't what you expect it
to be.

why not run through a debugger and see what the values are and compare them
to what you'd expect them to be?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top