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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect syntax on CType function

Status
Not open for further replies.

BunBo900

MIS
Dec 11, 2009
50
US
Hello,

I have a vb.net page and sql server 2008 back end.

I got an error: incorrect syntax near ','.

I have been researching and I tired different ways but no luck. Please point me to the right direction. I checked the syntax and it is correct to me.

Thanks.

Code:
Private Sub getCounts(ByRef GuestCount As Label, ByRef ReservationCount As Label, ByVal SqlDataSource1 As SqlDataSource)

 Dim dv As DataView 
 dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView) [b]****Error here****[/b]        
 Dim dr As DataRow
 Dim iReservationCount As Integer = 0
 Dim iGuestCount As Integer = 0
 For Each dr In dv.Table.Rows
    iGuestCount = iGuestCount + dr("PartySize")
    iReservationCount = iReservationCount + 1
  Next
    GuestCount.Text = iGuestCount.ToString()
    ReservationCount.Text = iReservationCount.ToString()

End Sub
 
I used your code and didn't get an error. you must have a syntax error elsewhere in your code.
 
Thanks for a quick response. The error showing on the code line below and not sure where else to look. This page was working and no changes been made to it. Is it possible the backend got changed that is why it is showing that error? Thanks.

Code:
Dim dv As DataView 
dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView) ****Error here: Incorrect syntax near ','****
 
Sounds like the sql (stored procedure) was changed and has the syntax error, not the asp.net code. This is why you should use Try...Catch blocks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top