c# 读取odbc数据库,注释详细

时间:2023-07-10 11:06:10
【文件属性】:
文件名称:c# 读取odbc数据库,注释详细
文件大小:44KB
文件格式:RAR
更新时间:2023-07-10 11:06:10
C# Odbc 包括Odbc数据库dsn的获取,表名的获取.界面代码概览:public Form1() { InitializeComponent(); List dsnNames = DataSource.GetAllDSN(); //读取DSN for (int i = 0; i < dsnNames.Count; i++) { this.comboBox1.Items.Add(dsnNames[i]); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboBox1.SelectedIndex == -1) { return; } List sheetNames = new List(); try { DataSource.ConnectToDataBase(this.comboBox1.SelectedItem.ToString(), this.txtUserName.Text, this.txtPassword.Text); sheetNames = DataSource.GetTableAndViewNamesFromDataBase(); } catch (Exception err) { MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < sheetNames.Count; i++) { this.comboBox2.Items.Add(sheetNames[i]); } } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt; DataSource.GetTableFromDataBase(this.comboBox2.SelectedItem.ToString(),out dt); this.dataGridView1.DataSource = dt; }
【文件预览】:
ReadOdbc
----ReadOdbc.sln(1KB)
----ReadOdbc()
--------ReadOdbc.csproj(4KB)
--------DataSource.cs(6KB)
--------Form1.cs(2KB)
--------Program.cs(520B)
--------Form1.resx(6KB)
--------Properties()
--------Form1.Designer.cs(9KB)
--------App.config(189B)
--------obj()
--------bin()
----.vs()
--------ReadOdbc()

网友评论