Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

cannot update value - LINQ

Posted on 2009-04-07
4
Medium Priority
?
213 Views
Last Modified: 2013-11-11
I want update a property in a table (i' am using MS SQL server database) , but it get this error
" THIS PROPERTY IS READONLY"

how do i fix this?

also when I declare  a new linq database instance,
Dim Db As New SageEMSArchiveDataContext
I only get 4 overidable properties (normally this is 5)

I have
import  system.linq

I have checked my references, also stangely another project(on my system) does not have this issue.

any idea why this happens?




Dim Db As New SageEMSArchiveDataContext("Data Source=ADELN250;Initial Catalog=SageEMS;Integrated Security=True")
 
        Dim tbFile = (From files In Db.tbFiles _
                   Select files.Filename, files.ArchiveLocation Where Filename = fName).ToList(0)
 
        If Not tbFile Is Nothing Then
            tbFile.ArchiveLocation = "asdf" 'AT THIS POINT I GET AN ERROR SAYING THAT THIS PROPERTY IS READONLY
        End If

Open in new window

0
Comment
Question by:manivineet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24092909
0
 

Author Comment

by:manivineet
ID: 24093037
no that didn't help at all
0
 
LVL 21

Accepted Solution

by:
naspinski earned 1500 total points
ID: 24094121
It is because you aren't selecting the whole item, just a few fields.  If you select a few fields, it is just for reading, as each entity does not have a key to tell the DB which one it is.  Just change

Dim tbFile = (From files In Db.tbFiles _
                   Select files.Filename, files.ArchiveLocation Where Filename = fName).ToList(0)

to
Dim tbFile = From files In Db.tbFiles _ files

Open in new window

0
 

Author Comment

by:manivineet
ID: 24134262
well the problem was that my table didn't have primary key.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question