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
VulpesPosted Aug 3, 2012, 6:30 AM
cool kidPosted Aug 3, 2012, 12:08 PM
VulpesPosted Aug 3, 2012, 12:04 PM
SQL doesn't support arrays so you have to use comma separated strings, or the like, instead.
cool kidPosted Aug 3, 2012, 11:22 AM
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?
VulpesPosted Aug 3, 2012, 9:13 AM
cool kidPosted Aug 3, 2012, 7:44 AM
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.
cool kidPosted Aug 3, 2012, 7:20 AM
cool kidPosted Aug 3, 2012, 2:50 AM
Thanks in advance
VulpesPosted Aug 2, 2012, 3:39 PM
sql2 = "UPDATE bookingDetails SET " & forbook(i).ToString() & " = 'booked' WHERE bookingDate=@bookingDate AND startTime=@startTime AND endTime=@endTime AND storeId=@storeId"