|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Specified cast is not valid
Hi
Need some help!! Have been working on a project that lets me connect to my Ms access database and display the data in a datagrid. This bit works fine, however when i try to add a new record to a table or update a record using the edit function of the datagrid (which also works gd) i get an "Specified cast is not valid" The code where the exception comes from For i = 0 To e.Item.Cells.Count - 3 Line 129: strText = CType(e.Item.Cells(i).Controls(0), _ (This is the problem) Line 130: TextBox).Text The whole function Function UpdateDataStore(ByVal e As DataGridCommandEventArgs) AsBoolean Dim i, j AsInteger Dim params(4) AsString Dim strText AsString Dim blnGo AsBoolean = True j = 0 For i = 0 To e.Item.Cells.Count - 3 strText = CType(e.Item.Cells(i).Controls(0), _ TextBox).Text If strText <> "" Then params(j) = strText Else blnGo = False lblMessage.Text = lblMessage.Text & "You forgot to enter a value" EndIf Next IfNot blnGo Then ReturnFalse ExitFunction EndIf Dim strSQL AsString = "UPDATE tblMember SET " & _ "MemberFirstname = `" & params(0) & "`," & _ "MemberSurname = `" & params(1) & "`," & _ "Address = `" & params(2) & "`," & _ "MemberFirstname = `" & params(3) & "`," & _ " WHERE User ID = " & CType(e.Item.Cells(0).Controls(1), Label).Text ExecuteStatement(strSQL) Return blnGo EndFunction Any help would be fantastic |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Specified cast is not valid |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|