|
-
Jul 26th, 2008, 11:41 AM
#1
Thread Starter
New Member
[RESOLVED] Value of type 'System.Linq.IQueryable(Of Integer)' cannot be converted to 'Integer'.
VB 2008, SQL Server 2005 Express, Using LINQ
Dim db As New CasinoHRDataContext
Dim deptid = From d In db.Departments _
Where d.Department _
Like Me.ListBoxDepartments.SelectedItem.ToString _
Order By d.DepartmentID _
Select d.DepartmentID
'Label1.Text = deptid.Single.ToString
Dim add As New Position With {.DepartmentID = deptid, .Position = txtPosition.Text}
db.Positions.InsertOnSubmit(add)
db.SubmitChanges()
txtPosition.Text = ""
showTable()
Hi i'm trying to add a new record to table positions this has a fk from table departments. I use a query to return the departmentID based on what is selected in listboxdepartments. I've checked that the right departmentID is being returned (hence the label1.text = deptid.single.tostring).
In the add variable i'm getting the following error for deptid (Value of type 'System.Linq.IQueryable(Of Integer)' cannot be converted to 'Integer'.)
it's some kind of conversion error but i'm not sure where to go from here. All help appreciated.
regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|