G
Guest
Hi
I am trying to run a query that will return a date. I wanted to pass the contents of an arraylist as a parameter to the query. The query will need to be run many times for each value in the arraylist so i have placed the code in a loop. What i am confused on is how i actullay use the values of the arraylist as a parameter to the query?
I have tried the following....
cmdArrivalDt.Parameters("@InvNo").Value = AvailCaraInv(i
but this does not seem to pass the value in!!
Here is my full code. Can anyone plz help me
Dim InvNo = AvailCaraInv(i
Dim cmdArrivalDt As New SqlCommand("Select min(a.Dt_Of_Arrival) from Booking a, Caravan_Booking b Where @Prop_departure_dt < Dt_Of_Arrival AND Caravan_Inv_No = @InvNo", Cn
cmdArrivalDt.CommandType = CommandType.Tex
'declare the parameter
cmdArrivalDt.Parameters.Add("@Prop_departure_dt", SqlDbType.DateTime
cmdArrivalDt.Parameters.Add("@InvNo", SqlDbType.Char, 5
'now set the value
cmdArrivalDt.Parameters("@Prop_departure_dt").Value = dtp2.Tex
cmdArrivalDt.Parameters("@InvNo").Value = AvailCaraInv(i
For i = 0 To AvailCaraInv.Count -
Tr
Cn.Open(
Dim reader1 As SqlDataReade
reader1 = cmdArrivalDt.ExecuteReader(
reader1.Read(
lblArrivalDt.Text = (reader1.GetSqlString(0).ToString
Catch ex As Exceptio
MsgBox(ex.Message
Finall
Cn.Close(
End Tr
Nex
I am trying to run a query that will return a date. I wanted to pass the contents of an arraylist as a parameter to the query. The query will need to be run many times for each value in the arraylist so i have placed the code in a loop. What i am confused on is how i actullay use the values of the arraylist as a parameter to the query?
I have tried the following....
cmdArrivalDt.Parameters("@InvNo").Value = AvailCaraInv(i
but this does not seem to pass the value in!!
Here is my full code. Can anyone plz help me
Dim InvNo = AvailCaraInv(i
Dim cmdArrivalDt As New SqlCommand("Select min(a.Dt_Of_Arrival) from Booking a, Caravan_Booking b Where @Prop_departure_dt < Dt_Of_Arrival AND Caravan_Inv_No = @InvNo", Cn
cmdArrivalDt.CommandType = CommandType.Tex
'declare the parameter
cmdArrivalDt.Parameters.Add("@Prop_departure_dt", SqlDbType.DateTime
cmdArrivalDt.Parameters.Add("@InvNo", SqlDbType.Char, 5
'now set the value
cmdArrivalDt.Parameters("@Prop_departure_dt").Value = dtp2.Tex
cmdArrivalDt.Parameters("@InvNo").Value = AvailCaraInv(i
For i = 0 To AvailCaraInv.Count -
Tr
Cn.Open(
Dim reader1 As SqlDataReade
reader1 = cmdArrivalDt.ExecuteReader(
reader1.Read(
lblArrivalDt.Text = (reader1.GetSqlString(0).ToString
Catch ex As Exceptio
MsgBox(ex.Message
Finall
Cn.Close(
End Tr
Nex