Using + and & signs (Gluing Strings Together)

Bluesmen

New Member
in Classic ASP I was using plus sings and ampersands in a string like this"<BR>arr=arr+myDataReader.item("columnsname")+"?#$"<BR><BR>but ASP.NET is telling me that "Type-declaration character '&' does not <BR>match declared data type 'System.Array'."<BR><BR>Or<BR><BR>The operands to '+' are of types 'System.Array' and 'System.Object', which <BR>are not appropriate for this operator<BR><BR>Is there a way to add these things together in ASP.NET?<BR><% @page LANGUAGE="c#" TRACE="false" %><BR><% @import Namespace="System" %><BR><% @import Namespace="System.Data" %><BR><% @import Namespace="System.Data.OleDb " %><BR><% <BR> string strDSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"c:\dbProducts.mdb\"";<BR> string strSQL="SELECT * from tblProducts";<BR> OleDbConnection cnConn=new OleDbConnection(strDSN);<BR> cnConn.Open();<BR> OleDbCommand cmCom = new OleDbCommand (strSQL,cnConn);<BR> OleDbDataReader myReader;<BR> myReader=cmCom.ExecuteReader();<BR> while (myReader.Read()) <BR> {<BR> string arr="OUTPUT - ";<BR> arr=arr + myReader["myColumn"] + "?#$";<BR> Response.Write(arr+ "< BR >");<BR> }<BR>%><BR>But what about in VB? <BR><BR>I keep hearing the + sign works in C#, but I'm getting the errors in VB<% @page LANGUAGE="vb" TRACE="false" %><BR><% @import Namespace="System" %><BR><% @import Namespace="System.Data" %><BR><% @import Namespace="System.Data.OleDb " %><BR><% <BR>dim arr as string<BR>dim strDSN as string<BR>dim strSQL as string<BR>dim myReader as OleDbDataReader <BR><BR> strDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\dbProducts.mdb'"<BR> strSQL ="SELECT * from tblProducts"<BR><BR> dim cnConn as new OleDbConnection(strDSN)<BR><BR> cnConn.Open()<BR> dim cmCom as new OleDbCommand (strSQL,cnConn)<BR><BR> myReader=cmCom.ExecuteReader()<BR> do while (myReader.Read()) <BR> arr="OUTPUT &+ : "<BR> arr=arr + myReader("txtEAN") & "?#$"<BR> Response.Write(arr+ "<BR>")<BR> loop<BR>%><BR><BR><BR>I found that both & and + worked
 
Back
Top