码迷,mamicode.com
首页 > 数据库 > 详细

Csharp: read Sybase SQL anywhere5.5 using c#

时间:2018-02-08 16:30:19      阅读:176      评论:0      收藏:0      [点我收藏+]

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

技术分享图片

  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   

原文地址:https://www.cnblogs.com/geovindu/p/8431988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!