Ciao a tutti,
ecco il mio problema: Mi capita una cosa stranissima, ho una query di select nel page_load e nel while richiamo una Sub dove mi fa una sottrazione ed un update, se avvio la pagina web da localhost... la Sub non viene richiamata... è come se fosse ignorata, quindi mi sono andato a fare il debug passo passo con VisualStudio e funziona tutto perfettamente. Da cosa può dipendere???
Vi posto il codice per maggior chiarezza:
Questa è la funzione nel page_load
Questa la Sub Sottrai che richiamo nel while:codice:strsql = "Select id_carrello, id_prodotto, quantita, id_taglia From Dettaglio_Ordine where id_carrello=" & id_carrello cmdSql = New OleDbCommand(strsql, conn) rs = cmdSql.ExecuteReader() While rs.Read() If VarType(rs("quantita")) <> 1 Then var_quantita = rs("quantita") End If If VarType(rs("id_prodotto")) <> 1 Then id_prodotto = rs("id_prodotto") End If If VarType(rs("id_taglia")) <> 1 Then id_taglia = rs("id_taglia") End If 'If var_quantita > 0 Then Sottrai(var_quantita, id_prodotto, id_taglia) 'End If End While
Grazie a tutticodice:Sub Sottrai(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer) Dim strconn1 As String Dim conn1 As OleDbConnection Dim rs1 As OleDbDataReader strconn1 = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & Server.MapPath(".") & "." & ConfigurationSettings.AppSettings("7xxx") conn1 = New OleDbConnection(strconn1) conn1.Open() Dim n_rimanenti As Integer strsql = "Select n_rimanenti From Prodotti where id_prodotto=" & y cmdSql = New OleDbCommand(strsql, conn1) rs1 = cmdSql.ExecuteReader() While rs1.Read() If VarType(rs1("n_rimanenti")) <> 1 Then n_rimanenti = rs1("n_rimanenti") End If End While strsql = "Update Prodotti set" strsql = strsql & " n_rimanenti=" & (n_rimanenti - x) strsql = strsql & " where id_prodotto=" & y '& " and id_taglia=" & z cmdSql = New OleDbCommand(strsql, conn1) cmdSql.ExecuteNonQuery() conn1.Close() End Sub

Rispondi quotando