.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 14th, 2004, 12:50 PM
jatiro jatiro is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 jatiro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Specified cast is not valid


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway