当前位置:Gxlcms > 数据库问题 > Csharp: read Sybase SQL anywhere5.5 using c#

Csharp: read Sybase SQL anywhere5.5 using c#

时间:2021-07-01 10:21:17 帮助过:3人阅读

技术分享图片

  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#

标签:dbn   click   message   sha   技术   src   UI   from   cat   

人气教程排行