static public void Main() { string myConnectionString = "Host=myserver.mycompany.com;" + "User Id=myname;PWD=mypass;" + "Database=mydatabase"; using (DbConnection conn = new IngresConnection()) { conn.ConnectionString = myConnectionString; conn.Open(); // open the Ingres connection string cmdtext = "select table_owner, table_name, " + " create_date from iitables " + " where table_type in ('T','V') and " + " table_name not like 'ii%' and" + " table_name not like 'II%'"; DbCommand cmd = conn.CreateCommand(); cmd.CommandText = cmdtext; DataSet ds = new DataSet("my_list_of_tables"); // read the data using the DataAdapter method DbDataAdapter adapter = new IngresDataAdapter(); adapter.SelectCommand = cmd; adapter.Fill(ds); // execute the query and fill the dataset // write the dataset to an XML file ds.WriteXml("c:/temp/temp.xml"); } // close the connection } // end Main()
static void Main(string[] args) { string SQLStatement = "select * from revenue"; // SQLStatement = "delete from revenue"; // SQLStatement = "insert into revenue(myid, material, revenue) values(1, 'Flower', 12.34)"; // SQLStatement = "insert into revenue(myid, material, revenue) values(2, 'car', 1.34)"; // SQLStatement = "insert into revenue(myid, material, revenue) values(3, '花', 26.989)"; // SQLStatement = "insert into revenue(myid, material, revenue) values(3, '汽车',26.989)"; IngresConnection con = new IngresConnection(string.Format("Host={0};Database={1};Uid={2};Pwd={3}", "XXX", "demodb", "Administrator", "HX")); IngresDataAdapter da = new IngresDataAdapter(new IngresCommand(SQLStatement, con)); DataTable sqlresult = new DataTable(); da.Fill(sqlresult); con.Close(); da.Dispose(); foreach (DataColumn sqlcol in sqlresult.Columns) { Console.WriteLine(sqlcol.DataType); } Console.WriteLine(sqlresult.Rows.Count); Console.Read(); }
private DataTable GetSQLTable(CustomListData data) { IngresConnection con = GetConnection(data); data.Properties.TryGetValue("SQLStatement", StringComparison.OrdinalIgnoreCase, out var SQLStatement); IngresDataAdapter da = new IngresDataAdapter(new IngresCommand(SQLStatement, con)); DataTable sqlresult = new DataTable(); da.Fill(sqlresult); con.Close(); da.Dispose(); return(sqlresult); }
private void read() { this.dt = new System.Data.DataTable(); IngresConnection con = new IngresConnection(Login.myConnectionString); string query = "select * from read_rol"; IngresCommand comm = new IngresCommand(query, con); con.Open(); IngresDataAdapter adapt = new IngresDataAdapter(comm); adapt.Fill(this.dt); con.Close(); this.metroGrid1.DataSource = this.dt; adapt.Dispose(); }