13-01-2006, 11:28
|
|
|
חבר מתאריך: 10.12.05
הודעות: 545
|
|
פונקציה לעדכון מידע במסד נתונים - שגיאה
שלום
קטע הקוד הבא (המסומן בקו תחתון:
קוד:
Function updatedatastore(ByVal e As DataGridCommandEventArgs) AsBoolean
Dim i, j AsInteger
Dim params(4) AsString
Dim strtext AsString
Dim cl AsBoolean = True
j = 0
For i = 1 To e.Item.Cells.Count - 3
strtext = CType(e.Item.Cells(i).Controls(0), TextBox).Text
If strtext <> ""Then
params(j) = strtext
j = j + 1
Else
cl = False
Label1.Text = "תקלה"
EndIf
Next
IfNot cl Then
ReturnFalse
ExitFunction
EndIf
Dim strsql AsString = "UPDATE tblProvider SET " & _
"Provider_Name = '" & params(0) & "'," & _
"Address = '" & params(1) & "'," & _
"State = '" & params(2) & "'," & _
"ZIP = '" & params(3) & "'," & _
" WHERE Provider_ID = " & CType(e.Item.Cells(0).Controls(1), Label).Text
executestatement(strsql)
Return cl
EndFunction
גורם לשגיאה הבאה:
קוד:
System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.HyperLink' to type 'System.Web.UI.WebControls.TextBox'.
יש למישהו מושג מה זה אומר?
תודה.
|