Something happened to some of the files in my visual studio project so I had to transfer the working files to a new project.
Everything is working fine except when I try to add new stuff to my database (like a new column) linq to sql does not recognize the changes.
At one point (I think when I opened up the dbml file) something popped up on visual studio saying something to the effect, that the link to the database (I am not sure if it mentioned web.config) is incorrect so they are just going to use the link in the dbml file (or something like that).
How do I get the correct link? and where do I put it?
So linq to sql will recognize changes?
You can right click on any white space on your ".DBML" file and then go to properties option. You'll be able to find the "Conexión(Connection)" option in where there'll be listed all your SQL connections, just pick one and that's it.
Once you have this done Visual Studio will recognize your future changes.
Note: This will help you to establish or change the connection with your SQL server. If you want to update your DBML scheme you can read this: How do I update a Linq to SQL dbml file?
Related
I'm busy writing a small app and I only want a database to load small amounts of data, in other words I don't need the functionality of SQL.
So I've installed filehelpers, but it seems very limited in the sense that I can read/write and even append data, but it seem impossible to delete one row of data in a table?
Does anyone know how to do this with filehelpers or point me to a different solution where I can just add a local db to my app without any other external software required?
PS. My visual studio does not have the "create local db" from the item selection.
For something like this, I'd use an embedded SQLite database. It gives you the best of both worlds, one file database for local data and most of the features of SQL.
See here: https://sqlite.org/
On their download page, they have lots of stuff and a plugin for VS:
https://sqlite.org/download.html
I'm making a WinForms app in C#. When I go to create my database object, I'm presented with two options:
Local Database
Service-based Database
All I want is a simple local database to use for my project.
However, if I select "Local Database (Compact Edition)" then after I create my tables and drag them over to a LINQ-To-SQL Class creator it says:
The selected object(s) use an unsupported data provider.
So, I don't know why creating a local database would be considered an unsupported provider when dragging to tables to the Object Relational designer.
So, I try the second type, "Service-based Database". I lay out my tables how I want for my basic application and make my tables. The LINQ-To-SQL Designer works fine when I drag these tables and I proceed to write my code in my app to insert and upate the database entries.
However, with this second "Service-based Database" my inserts and updates work as long as the application is running. However, once I close it it reverts back to what it was before. If I manually add in data via the Server Explorer it persists but any inserts I do don't save.
Why can't I create and use a Local Database with LINQ?
If that isn't an option, then why isn't the "Service-Based Database" (whatever that is), persisting beyond the application closing?
Thanks for your time!
Edit: Apparently the LINQ-To-SQL Object Designer doesn't work on Compact Edition Local Databases. It can still be done, but you have to use SqlMetal apparently to generate the dmbl file.
When you compile, the old database gets erased and a new one is copied to the bin folder. Therefore try link (using linq) to the database in the bin folder. Try change your connectionString.
So I have a database filled with values already. It works fine, until I start to query any values I have added into it. It just won't work.
I'm using a project on Visual Studio creating a Web Form, while the database connection, as well as the add, update, and delete methods, are stored in a DLL that I referenced.
The adding works, and so does the updating. I can see it in the database through the server explorer, but I cannot query what I am seeing. I tried querying values I did not add, and it works. When I query the rows I added, it won't work.
Let me know if you need anymore information. I have no idea what's going on.
I've encountered a similar issue and the catch to it was that it was actually using another database. I'd recommend you check with SQL Server Management Studio and make sure you're using the correct database and also have a look in Webconfig.
I can't understand how to manage database with Entity Framework.
I'll try to describe my problem step-by-step
create winforms application
add database (.mdf) to solution
when appears window "choosing database model", select dataset
then finish, as database is empty
go to server explorer, choose created database, create some tables
add to solution EDM ADO.NET
The problem is that new data doesn't appear in my database in server explorer. This means that while my Winforms app is working, I can modify my database (change existing values, add new, ..). but if I close my app, there is no update in my database in server explorer. I DON'T forget to use function SaveChanges()
P.S. while my app is working, values are updating. Think, that means that data updates in dataset, but not in database. if i am right, give a clue how to update database from dataset.
pps. visual studio 2010 ultimate. sorry for english
dbentity db=new dbentity();
db.items.addobject(new item() {value=something});
db.savechanges();
Don't add the database to your solution. You can use the Server Explorer to add a connection to your database via your existing SQL Server, or you can select your database in the wizard that appears when adding a new EDMX file to your solution.
Did you try either of these? Where did you get stuck?
I'm making a WinForms app in C#. When I go to create my database object, I'm presented with two options:
Local Database
Service-based Database
All I want is a simple local database to use for my project.
However, if I select "Local Database (Compact Edition)" then after I create my tables and drag them over to a LINQ-To-SQL Class creator it says:
The selected object(s) use an unsupported data provider.
So, I don't know why creating a local database would be considered an unsupported provider when dragging to tables to the Object Relational designer.
So, I try the second type, "Service-based Database". I lay out my tables how I want for my basic application and make my tables. The LINQ-To-SQL Designer works fine when I drag these tables and I proceed to write my code in my app to insert and upate the database entries.
However, with this second "Service-based Database" my inserts and updates work as long as the application is running. However, once I close it it reverts back to what it was before. If I manually add in data via the Server Explorer it persists but any inserts I do don't save.
Why can't I create and use a Local Database with LINQ?
If that isn't an option, then why isn't the "Service-Based Database" (whatever that is), persisting beyond the application closing?
Thanks for your time!
Edit: Apparently the LINQ-To-SQL Object Designer doesn't work on Compact Edition Local Databases. It can still be done, but you have to use SqlMetal apparently to generate the dmbl file.
When you compile, the old database gets erased and a new one is copied to the bin folder. Therefore try link (using linq) to the database in the bin folder. Try change your connectionString.