hi there,
Im doing a reservation seats. In my database i have a columns t1,t2,t3 and etc where i want to assign it to 'booked'. But i keep getting error near "=". I tried and it seems the error is from the array part
Dim s As String = lblSelected.Text.ToString()
Dim forbook() As String
forbook = Split(s, ",")
For i As Integer = 0 To UBound(forbook)
mycn2.Open()
sql2 = "UPDATE bookingDetails SET '" & forbook(i).ToString() & "'='booked' WHERE bookingDate=@bookingDate AND startTime=@startTime AND endTime=@endTime AND storeId=@storeId"
cmd2.Parameters.AddWithValue("@bookingDate",DateTime.Parse(bookingDAte.ToString(formatDate)))
cmd2.Parameters.AddWithValue("@startTime", startTime)
cmd2.Parameters.AddWithValue("@endTime", endTime)
cmd2.Parameters.AddWithValue("@storeId", storeId)
cmd2.ExecuteNonQuery()
Next
mycn.close()
Any help would be much appreciated. Thanks in advance.
Loading

VulpesRank #55 · 29.2K reputationPosted Aug 3, 2012, 2:30 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 2, 2012, 11:39 AM EDT
sql2 = "UPDATE bookingDetails SET " & forbook(i).ToString() & " = 'booked' WHERE bookingDate=@bookingDate AND startTime=@startTime AND endTime=@endTime AND storeId=@storeId"
cool kid11 reputationPosted Aug 2, 2012, 10:50 PM EDT
Thanks in advance
cool kid11 reputationPosted Aug 3, 2012, 3:20 AM EDT
cool kid11 reputationPosted Aug 3, 2012, 3:44 AM EDT
While rea.Read()
For j As Integer = 1 To 24
Dim t As String = "t" & j //column name
If (rea(t.ToString()).ToString() = "booked") Then
Dim img As ImageButton = DirectCast(pnl2.FindControl(t.ToString()), ImageButton)
img.ImageUrl = "~/images/bookTable.png"
img.Enabled = False
End If
Next
End While
Is there anything missing in my codes? Thanks in advance.
VulpesRank #55 · 29.2K reputationPosted Aug 3, 2012, 5:13 AM EDT
cool kid11 reputationPosted Aug 3, 2012, 7:22 AM EDT
Thanks. You helped me alot.
Im wondering how can I set an array into a parameter instead of using string concatenation
in SQL statement?
Is there a way?
VulpesRank #55 · 29.2K reputationPosted Aug 3, 2012, 8:04 AM EDT
SQL doesn't support arrays so you have to use comma separated strings, or the like, instead.
cool kid11 reputationPosted Aug 3, 2012, 8:08 AM EDT