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 |
|
amitbadgi
Starting Member
29 Posts |
Posted - 2005-08-09 : 18:41:34
|
| I am converting an asp application to asp.net and I am using sql queries for an access database, I am getting a common error, here is the error,Exception Details: System.InvalidCastException: Operator '&' is not defined for string "select * from SISPREV_student wh" and type 'Field'.Source Error: Line 334: if trim(rs("offendertype").value) = "1" thenLine 335: rs_person = server.CreateObject("ADODB.recordset")Line 336: rs_person.open ("select * from SISPREV_student where stu_id = '" & rs("stu_id") & "' ", conn2, 1, 3)Line 337: Line 338: %> Source File: C:\Documents and Settings\amit\WebSite1\home.aspx Line: 336 Stack Trace: [InvalidCastException: Operator '&' is not defined for string "select * from SISPREV_student wh" and type 'Field'.] Microsoft.VisualBasic.CompilerServices.Operators.InvokeUserDefinedOperator(UserDefinedOperator Op, Object[] Arguments) +84 Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Object Left, Object Right) +209 ASP.home_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Documents and Settings\amit\WebSite1\home.aspx:336 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 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8879 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-08-09 : 18:56:31
|
I do not think this has much to do with your SQL statement. It looks like your error is due to syntax issues between ASP and ASP .NETFor example: Change instance of rs("stu_id") to rs.Fields("stu_id").ValueI would look here for more info:[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/convertasptoaspnet.asp[/url]Nathan Skerl |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-09 : 18:57:24
|
| More of a .NET issue than an SQL one, but here goes:Replace the ampersand with a plus. The error comes from the way you constructed the string, rather than the format of your SQL statement. |
 |
|
|
|
|
|
|
|