Reputation: 437
I need to move data between tables. The two tables are identical in terms of data type on each field. However when I try to take the data from one table and place it in the other i get errors. No doubt a very convoluted way of programming this but its the only way I know at this stage. For each of the fields I get Value of type 'System.Linq.IQueryable(Of Integer)' cannot be converted to Integer
or the equivalent, depending on data type. I have been struggling with this for 3 days. Please help!
`input string`
Dim parseRef As String = txtReferenceCode.Text
`Convert string to integer value`
Dim findRecord As Integer = Integer.Parse(parseRef)
`Query the database for the row to be updated.`
Dim modQuery = _
(From m In db.Modules
Join am In db.Amendments_Awaiting_Approvals On m.Module_code Equals am.Module_code
Where am.Amendments_ID = findRecord _
Select m)
Dim newName = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Module_name_app)
Dim newStatus = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Module_status_app)
Dim newCredits = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Module_credits_app)
Dim newCapacity = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Module_capacity_app)
Dim newFee = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Fee_change)
Dim newDesc = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Module_Description_app)
` Execute the query, and change the column values
you want to change. NB all fields on right had side hold the temp data to be input`
For Each m As [Module] In modQuery
m.Module_name = newName
m.Module_status = newStatus
m.Module_credits = newCredits
m.Module_capacity = newCapacity
m.Fee = newFee
m.Module_Description = newDesc
Upvotes: 0
Views: 2032
Reputation: 20140
if you expect only one row per query;
Dim newFee = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Fee_change)
by default this will return a "list" of Fee_change
Dim newFee = (From n In db.Amendments_Awaiting_Approvals
Where n.Amendments_ID = findRecord
Select n.Fee_change).FirstOrDefault
add .FirstOrDefault so it wont be a iqueryable anymore
Upvotes: 5