Visual Studio 2005 Error
I changed my several field data to UNICODE. after that when i compile the codes. the following error erised.
Character is not valid
my code is,
fdate = sDate
tdate = eDate
Dim sql
As
String =
""
'app = approved.Value.ToString
If ScheduleReport.cboDate.Text =
"Approved Date"
Then
sql =
"SELECT substring(ltrim(str(l.Blockid)),1,6) as CMapNo,l.lastupdate,l.approved, ac.dateofaction,l.StateOrPrivate, "
sql = sql +
"Nds.DSDNameSin, Nd.ProvinceSin, Nd.districtSin, substring(ltrim(str(l.Blockid)),7,2) as Block, "
sql = sql +
"l.Parcelno ,l.deedareainhec, Nc.GNNamesSin,Nc.VillagesSin, c.divisionno, "
sql = sql +
"No.nameinnicSin, No.address1sin + ', ' + No.citysin as Address,"
sql = sql +
"o.nicno,'' as Percentage, o.class,ltrim(dbo.GetEncum(l.Blockid,l.Parcelno)) as Encumbrance, "
sql = sql +
"ltrim(dbo.GetEncumTitle(l.Blockid,l.Parcelno)) as Title, blo.NoticeNo, blo.GazetteNo, "
sql = sql +
"blo.DateofPublished, blo.gnnames,blo.villages from landparcels l inner join owner o on l.blockid=o.blockid and "
sql = sql +
"l.parcelno = o.parcelno left join cmapno c on substring(ltrim(str(l.Blockid)),1,6)=c.cmapno"
sql = sql +
" left join dsddivision ds on c.divisionno=ds.divisionno "
sql = sql +
"left join district d on d.districtid=ds.districtid left join blocks blo on blo.blockid=l.blockid "
sql = sql +
"left join actions ac on (l.blockid=ac.blockid and l.parcelno=ac.parcelno)"
sql = sql +
"where l.approved='Yes' and (ac.actiontaken='Approved for 1st Class' "
sql = sql +
"or ac.actiontaken='Approved for 2nd Class') and (ac.dateofaction>='" & fdate &
"'"
sql = sql +
" and ac.dateofaction<='" & tdate &
"')"
sql = sql +
" and substring(ltrim(str(l.Blockid)),1,6) ='" & cmap &
"'"
sql = sql +
" and substring(ltrim(str(l.Blockid)),7,2) ='" & block &
"'"
sql = sql +
" order by substring(ltrim(str(l.Blockid)),1,6), substring(ltrim(str(l.Blockid)),7,2), l.Parcelno asc"
ElseIf ScheduleReport.cboDate.Text =
"Data Entered Date"
Then
tdate = DateAdd(DateInterval.Day, 1,
CDate(tdate))
sql =
"SELECT substring(ltrim(str(l.Blockid)),1,6) as CMapNo,l.lastupdate,l.approved, ac.dateofaction,l.StateOrPrivate, "
sql = sql +
"ds.DSDNameSin, d.ProvinceSin, d.districtSin, substring(ltrim(str(l.Blockid)),7,2) as Block, "
sql = sql +
"l.Parcelno ,l.deedareainhec, c.GNNamesSin,c.VillagesSin, c.divisionno, "
sql = sql +
"o.nameinnicSin, o.address1sin+ ', ' + o.citysin as Address,"
sql = sql +
"o.nicno,N'' as Percentage, o.class,ltrim(dbo.GetEncum(l.Blockid,l.Parcelno)) as Encumbrance, "
sql = sql +
"ltrim(dbo.GetEncumTitle(l.Blockid,l.Parcelno)) as Title, blo.NoticeNo, blo.GazetteNo, "
sql = sql +
"blo.DateofPublished, blo.gnnames,blo.villages from landparcels l inner join owner o on l.blockid=o.blockid and "
sql = sql +
"l.parcelno = o.parcelno left join cmapno c on substring(ltrim(str(l.Blockid)),1,6)=c.cmapno"
sql = sql +
" left join dsddivision ds on c.divisionno=ds.divisionno "
sql = sql +
"left join district d on d.districtid=ds.districtid left join blocks blo on blo.blockid=l.blockid "
sql = sql +
"left join actions ac on (l.blockid=ac.blockid and l.parcelno=ac.parcelno)"
sql = sql +
"where l.approved='Yes' and (ac.actiontaken='Approved for 1st Class' "
sql = sql +
"or ac.actiontaken='Approved for 2nd Class') and (l.lastupdate >='" & fdate &
"'"
sql = sql +
" and l.lastupdate <='" & tdate &
"')"
sql = sql +
" and substring(ltrim(str(l.Blockid)),1,6) ='" & cmap &
"'"
sql = sql +
" and substring(ltrim(str(l.Blockid)),7,2) ='" & block &
"'"
sql = sql +
" order by substring(ltrim(str(l.Blockid)),1,6), substring(ltrim(str(l.Blockid)),7,2), l.Parcelno asc"
End
If
sqlCon.Open()
myDAforLPs =
New SqlDataAdapter(sql, sqlCon)
myDSforLPs =
New DataSet()
myDAforLPs.Fill(myDSforLPs,
"Actions")
sqlCon.Close()
Pl help me
Chandana
January 16th, 2011 4:47am
I think that is more related VS rather than SQL Server , what line of the code throws the error?Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
January 16th, 2011 5:09am
Thanks It is ok.
I want to assing a primary key like this
Dim MyPrimarykey(0) as DataColumn
Dim findTheseVals(1) as Object
MyPrimarykey(0) = myDSGN.Tables("Villages").Columns("VillagesSin")
myDSGN.Tables("Villages").Primarykey = MyPrimarykey
findTheseVals(0) = "0101"
findTheseVals(1) = "Some Unicode data"
Dim myrow as DataRow
myrow = myDSGN.Tables("Villages").Rows.Find(findTheseVals)
These codes work with non unicode chars
But with unicode The following error occured
"These columns don't currently have unique values"
why is that
Can u help meChandana
January 17th, 2011 5:45am