var connectionString = new SqliteConnectionStringBuilder(baseConnectionString)Ī basic connection string with a shared cache for improved concurrency. It can also be used to prevent connection string injection attacks. You can use SqliteConnectionStringBuilder as a strongly typed way of creating connection strings. The Pooling keyword was added in version 6.0. When specified, PRAGMA key is sent immediately after opening the connection. This mode can change the behavior of transaction and table locking. This is the default.Ĭonnections share a cache. Uses the default mode of the underlying SQLite library. Opens the database for reading and writing. Opens the database for reading and writing, and creates it if it doesn't exist. This keyword also supports URI Filenames. If set, paths are made relative to the DataDirectory application domain property value. Paths that start with the |DataDirectory| substitution string are treated the same as relative paths. For more information, see In-Memory databases. If :memory:, an in-memory database is used. If empty, SQLite creates a temporary on-disk database that's deleted when the connection is closed. SQLite treats paths relative to the current working directory. DataSource (without a space) and Filename are aliases of this keyword. The following connection string keywords can be used with : Data Source Connection strings in įollow the standard ADO.NET syntax as a semicolon-separated list of select *įrom sys.tables -to fetch list of tables from the DB which you app connected toįrom IAMS_Discr_ connection string is used to specify how to connect to the database. In your case, you can have your query of stored procedure similar to below queries. You can query any data base if all DB are in same server and instance, see example below. If you want to access multiple data bases of one server and one instance, It is enough to have one connection to one database in that server and instance, provided user has access to those DBs. (Eg: t_users in db_1 and db_2)ģ) If you have confined to two data bases, use where clause in the above said (1) This is useful choice, as there is a possibility of having a table with same name in two data bases. Refer: How do I list all tables in all databases in SQL Server in a single result set?Ģ) Or you can provide another combo box to display list of data bases, prior to tables combo box, once user chooses a DB name, pass it to the query. MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ġ) If you want to show all the tables in all the data bases please populate the combo box the same. SqlDataAdapter sqlDataAdap = new SqlDataAdapter(sqlCmd) ĭ = "table_name ASC" SqlCmd.CommandText = "Select table_name from information_schema.tables" SqlConnection con = new SqlConnection(strConnection) String strConnection = Source=SERVER_NAME Initial Catalog =" + selectedbase+ " User ID =USER Password =PASS " Private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) WHEN I SELECT DATABASE IN COMBOBOX2, COMBOBOX1 DISPLAYS TABLES IN THAT DATABASE String ComboBoxSelected = ComboBox1.GetItemText(ComboBox1.SelectedItem) SqlConnection con = new Source=SERVER_NAME Initial Catalog =" + DBselected + " User ID=USER Password=PASS ") Private void ShowTbl_Click(object sender, EventArgs e) BUTTON FOR SHOWING TABELS IN DATAGRIDVIEW SqlDataAdapter sqlDataAdap2 = new SqlDataAdapter(sqlCmd2) SqlCmd2.CommandText = "SELECT name FROM sys.databases EXCEPT SELECT name FROM sys.databases WHERE name='master' OR name='model' OR name='msdb' OR name='tempdb'" SqlConnection con2 = new SqlConnection(stringConnection) String stringConnection = Source=SERVER_NAME Initial Catalog =DB_NAME User ID =USER Password =PASS " Private void Form1_Load(object sender, EventArgs e) Here is some part of my code with solution: public partial class Form1 : Form It is much easier for me to work wit two comboboxes using different connections. When i choose a database in first combobox, the second one automaticly shows tabels in that database. I ended up using two comboboxes on my form.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |