Changing the schema of a table in SQLite in c# - c#

I am using SQLite DB to store data in my c# project. I have an existing table which has some records. Now I want to insert two more columns in existing table. How can I insert the data with my C# code for those two columns. Do I need to create the table again or altering the table will do?
The project also has designer.cs corresponding to that table which is getting generated automatically. I want to know how this file is getting generated.

for changing to schema in sqlite u need to make appropriate changes in .XSD file in your project. This will change the designer.cs automatically and ur schema will be changed. You can search ".xsd" in ur project and can go ahead.

Related

Add column in database then update the dbml

I have an application that have a dynamic table in database. The problem is, let say there's a change in table structure like addition of column, can I update the dbml file dynamically? so I don't have to fix the application everytime the column been added
Using the DBML and code generation approach, no there's no way to let your application take advantage of the changes automagically. The DBML results in new generated code which needs to be compiled, that requires the DSL Toolkit, Visual Studio and the .NET SDK to be present.

Create SQL server db, table, import programatically using Visual Studio 2012,C#

I'm losing the way when I'm look after controlling db and then populate it in aspx gridview, so I prefer to do this within Visual Studio.
I have multiple text files that I want to create for them SQL Server db and create and load the text files data into db tables based on column value.
[if text file column a value = 1 then
if sql db table 1 exist import else
create sql db table 1 and import]
All tables would be with the same structure.
If you direct me how to do this or guide me to a good tutorial. I read that I need to add a reference sqlmdo something to create db within vs but as it's not there I downloaded it but I didn't know how to add it to the assemblies. Main idea is to control and do this using vs....really thanks in advance.

How to import existing mdf file into a lightswitch project?

I would like to copy table definitions from an existing database file into a new lightswitch project, does anyone know how to do that, it seems like you can only create a new database from scratch or attach an external database, but when i try to attach an external mdf file from another VS project I get an error which states: CREATE DATABASE Permission denied in database 'master'.
Any ideas about how to copy the table definitions from an existing database file into a lightswitch project?
If you have the external database attached on an instance of SqlServer, you shouldn't have no problem attaching to it from LightSwitch. From that point on, you can rename tables and columns, change datatypes etc, as well as adding more tables and structures to that DB.
Note that the DB is supposed to be served from a SqlServer instance, not a file on your file system.
As far as I know it can't be done. Lightswitch holds a representation of the database tables separate from the actual database definition. You can probably go the other way however because when the ApplicationDatabase.mdf file does not exist you can start Lightswitch (you will notice the table definitions are still in there) and then build the app which will recreate your ApplicationDatabase.mdf. It is empty of course but If you could find out where lightswitch stores those table definitions (an *.xaml file somewhere?) you might be able to get those copied into your project and then generate the ApplicationDatabase.mdf from there?

TableAdapterManager and Related tables in MS Access

I am writing my first database application in c# and I have to use MS Access database, I have two tables Invoice and Order the order table is a child table. Invoice is a parent table it has key column "InvoiceNumber" which is auto column and it has a one to many relation with Order table column "InvoiceNumber". The problem I am having is that I got an exception at the line
tableAdapterManager.UpdateAll(database1DataSet);
when I try to add a new row and click save,
"You cannot add or change a record because a related record is required in table 'Invoice'."
I tried to search but I am unable to find it any help for ms access database, most of them are of SQL database. I also found one solution to edit the relation in the dataset designer to select the option "Both relation and foreign key constraints" but it didnot work for me either.
Thanks
Make sure that your OleDbParameters are properly set and in the correct corresponding order as the columns in the tables in the database. If you use Visual Studio automated code generation for data sources when you add a database, then drag and drop a table onto a form, check out the <database name>DataSet.Designer.cs file. It will teach you all you need to know.

visual studio DataSet designer with stored-procedures ? what is this icon

What does this icon mean is Visual studio, visual Data Set designer.
I have several stored procedures.
can you help me understand,
why the one on top of the list has a
small "check mark"
why I can't delete it if I need to.
This is not the case with the rest.
Why is this "special" ?
Thanks
Because that item contains the method(s) that define the schema of the table the TableAdapter is part of.
The default names are Fill and GetData. Looks like you renamed them.
Each table has a default query (The one on top with the check on it). When you dragged your tables in to the dataset to create the query, it wrote a SQL statement which it uses to schema your table. Keep that query simple, you might not actually use it in code, and you can always edit that query to update the table schema. In the picture you provided, your default query is actually a stored procedure.
Every time you open the default query it connects to your datasource and allows you to select new columns that weren't in there before. If you want to update your existing columns, delete all the columns out of the table before you attempt to open the query. When you save the query, your updated columns get added back.
Make sure your connection string has permissions to view column information.

Categories

Resources