Csharp: read Sybase SQL anywhere5.5 using c#
阿新 • • 發佈:2018-02-08
lec oid info clu dbf click nec select post
private void button1_Click(object sender, EventArgs e) { try { //OdbcConnection conn = new OdbcConnection(); //conn.ConnectionString = // "ODBC;" + // "Driver={Sybase SQL Anywhere 5.0};" + // "DefaultDir=c:\myfolder\;" + // "Dbf=c:\mypath\dbname.db;" + // "Uid=UserName;" + // "Pwd=Secret;" + // "Dsn="""";"; // Must be included! //conn.Open(); geovindu connectionString = "DSN=geovindu;UID=dba;PWD=sql;"; //Data Source=sademo using (OdbcConnection connection = new OdbcConnection(connectionString)) { connection.Open(); DataTable dt = new DataTable();// connection.GetSchema(); DataSet ds = new DataSet(); OdbcDataAdapter da = new OdbcDataAdapter("SELECT * FROM employee", connection); da.Fill(ds); dt = ds.Tables[0]; // Do work here. this.dataGridView1.DataSource = dt; } } catch (OdbcException ex) { MessageBox.Show(ex.Message.ToString()); } }
讀取數據如下:
Csharp: read Sybase SQL anywhere5.5 using c#