c# - Storing SQL Tables for use in visual studio -


I am trying to create a Windows Forms application that manipulates data from multiple tables stored on a SQL server.

  1. The application is running, while what is the best way to store data locally? I had the previous program that used to modify only one table, and it was set to use a datagrid view. However, as I do not necessarily have to see all the tables, I'm exploring another way to store data from the query SELECT * FROM ... .

  2. Is it better to switch tables, make changes to the C # application, and then update the modified tables at the end, or just remotely perform all the tasks on the database (tables Recovering every time

You can use a connection string and allocate to a DataTable, then you can make changes in the DataTable in any form you want. Once you have completed the changes, you can use the DataAdapter to make changes back into the database.

Here's how to get the table:

  Datatel table; (using SqlDbConnection connection = new SqlDbConnection (connectionString)) {connection.Open (); (SqlDbCommand command = new SqlDbCommand (tableName, using connections)) {command.CommandType = CommandType.TableDirect; SqlDbDataReader dr = command.ExecuteReader (CommandBehavior.CloseConnection); table = new datatable (tagname); routeID.Load (Dr.); }}  

How to the table after the changes, make sure that you provide to obtain changes to commit to a dataset to your Detatale:

 < Code> dataset dataset = new dataset (); DataSet.add (table); (Ed adapter = new SqlDbDataAdapter ( "SELECT * Using FROM" + tableName, connections)) (Adiapi) (adapter.Fill (dataSet, tableName); (var builder = new SqlDbCommandBuilder (adapter)); (DataSet newSet = dataSet .GetChanges (DataRowState.Added)) of {builder.QuotePrefix = "[" using; builder. QuoteSuffix = "]"; Adapter.InsertCommand = builder.GetInsertCommand (); Adapter.Update (newSet, tableName);}}}  

There may be some precedent types, I did not compile the errors to check errors.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -