On Feb 28, 3:45 pm, Schultz <[email protected]> wrote:
> Hello,
> I am new to Linq & DbLinq. I'm trying to update a single record in my
> MySql database but I receive the following error:
>
> System.InvalidCastException: Unable to cast object of type
> 'DbLinq.Data.Linq.Implementation.QueryProvider`1[cadetx.EventsDb]' to
> type 'cadetx.EventsDb'. at AdminV2.btnUpdate_Click(Object sender,
> EventArgs e) in C:\inetpub\wwwroot\Cadet-X V2\AdminV2.aspx.vb:line 241
>
> Here is the code:
>
> Dim conn As New
> MySqlConnection(SQLConnection.ConnectionString)
> Dim db As New cadetx.CxBeta(conn)
> Dim cxevent As cadetx.EventsDb = From c In db.EventsDb
> _
> Where c.EventID = hidEID.Value
> Select c
> cxevent.Date = txtDate.Text
> cxevent.Name = txtEvent.Text
> cxevent.Location = txtLocation.Text
> cxevent.Info = txtInfo.Text
> cxevent.C1 = chkClasses.Items(0).Selected
> cxevent.C2 = chkClasses.Items(1).Selected
> cxevent.C3 = chkClasses.Items(2).Selected
> cxevent.C4 = chkClasses.Items(3).Selected
> cxevent.Time = txtHrs.Text & ":" & txtMin.Text
> db.SubmitChanges()
>
> I am using v 0.19 of DbLinq and my class (cadetx) was generated using
> DbMetal.
>
> Thanks for the help!
Schultz, I think you must set the ffield cxevent.Time to a DateTime
object not set it to a text.
<old code>
cxevent.Time = txtHrs.Text & ":" & txtMin.Text
</old code>
<try something like>
cxevent.Time = DateTime.Parse(txtHrs.Text & ":" &
txtMin.Text).ToString("hh:mm")
</try something like>
At last I hope that works fine.
Michael
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.