Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 1.0/1.1
Un fatto strano con il calendario ed il datareader!!
martedì 18 luglio 2006 - 14.15
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
bluland
Profilo
| Guru
1.149
messaggi | Data Invio:
mar 18 lug 2006 - 14:15
ho il seguente codice:
Private Function ruolo() As String
Dim e As String = Request.ServerVariables("REMOTE_USER")
Dim b As String = e.Substring(8)
Dim queryUser As String = "select AO from OSM_User where [user] = '" & b & "' "
Me.connloc.Open()
'Dim da As New SqlDataAdapter(queryUser, Me.Connord)
Dim cmd As New SqlCommand(queryUser, Me.connloc)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'verifo CHE dr = null
If dr.HasRows Then
Do While dr.Read()
If IsDBNull(dr.GetString(0)) Then
Return (dr.GetString(0))
'dr.Close()
Else
Dim s As String = dr.GetString(0).Trim'
dr.Close()
Me.connloc.Close()
Return s
End If
Loop
End If
End Function
Private Sub dagrid_itembound(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles DgItem.ItemCommand
'prova con stringbuilder
Dim sb As New StringBuilder
sb.Append("Update ord_web")
sb.Append(" set Accepting_Date = CURRENT_TIMESTAMP")
sb.Append(" WHERE ID= @elemento")
Dim queryModifica As String = sb.ToString
Dim queryOrdspadett As String = "select * " & _
" from Ord_web " & _
"where SpA_Order= @elemento " & _
"order by Shipping_Date"
'preleva ruolo dalla funzione ruolo
Dim s As String = ruolo()
'per user che possono accettare gli ordini
If s = "admin" Then
Try
Me.connloc.Open()
Dim cmd As New SqlCommand(queryModifica, Me.connloc)
cmd.Parameters.Add("@elemento", e.Item.Cells(1).Text)
Dim read As SqlDataReader
read = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Me.connloc.Close()
'read.Close()
Catch ex As Exception
Finally
'refresh della griglia dopo l'accettazione di un determinato record
If Me.LstRic.SelectedItem.Value = "SpA_Order" Then
Me.connloc.Open()
Dim cmd As New SqlCommand(queryOrdspadett, Me.connloc)
cmd.Parameters.Add("@elemento", Me.Lstcampi.SelectedItem.Value)
Dim read As SqlDataReader
read = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Me.DgItem.DataSource = read
Me.DgItem.DataBind()
Me.DgItem.Visible = True
Me.Lblitem.Visible = True
ElseIf Me.LstRic.SelectedItem.Value = "Shipping_Date" Then
---> Me.txtcerca.Text = Me.Calendar1.SelectedDate.ToShortDateString <------ RIGA DA ELIMINARE PER NN AVERE ERRORE
Dim start As String
start = Year(Me.txtcerca.Text) & " / " & Month(Me.txtcerca.Text) & " / " & Day(Me.txtcerca.Text)
Dim ends As String
ends = Year(Me.txtcerca.Text) & "/" & Month(Me.txtcerca.Text) & "/" & Day(Me.txtcerca.Text) & " " & "23:59:59.999"
Dim queryData As String = "select * " & _
"from Ord_web where " & _
"(Shipping_Date between '" & start & "' and '" & ends & "') " & _
"and (id <> 1) " & _
"order by Shipping_Date"
Me.connloc.Open()
Dim cmd As New SqlCommand(queryData, Me.connloc)
Dim reads As SqlDataReader
reads = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Me.DgItem.DataSource = reads
----> Me.DgItem.DataBind() <-----ERRORE
Me.DgItem.Visible = True
Me.Lblitem.Visible = True
End If
End Try
End If
End Sub
SE SI VERIFICA LA CONDIZIONE Me.LstRic.SelectedItem.Value = "SpA_Order" tutto funziona cioe' mi trovo il datagrid aggiornato
invece SE SI VERIFICA LA CONDIZIONE "Shipping_Date" mi da errore:
Invalid attempt to Read when reader is closed.
POI se elimino la seguente riga: Me.txtcerca.Text = Me.Calendar1.SelectedDate.ToShortDateString subito dopo elseif
mi funziona!
LA DOMANDA E' CHE CENTRA CON IL DATAREADER??
SALUTI
ENZO
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !