我在做ODBC连接informix数据库的时候不知道odbcconnection.connectionstring的连接语句这么写请指教我一下

解决方案 »

  1.   

    Informix 
     ODBC 
     Informix 3.30:
    "Dsn='';Driver={INFORMIX 3.30 32 BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd 
     Informix-CLI 2.5:
    "Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd" 
     DSN 
     ODBC 
     DSN:
    "DSN=myDsn;Uid=username;Pwd=;" 
     File DSN:
    "FILEDSN=c:\myData.dsn;Uid=username;Pwd=;" 
      

  2.   

    http://www.csdn.net/develop/article/16/16437.shtm
      

  3.   

    大家帮忙看看我的程序错在什么地方好吗?运行在(r = this.odbcCommand1.ExecuteReader();)提示系统错误namespace WindowsApplication2
    {
    /// <summary>
    /// DataForm1 的摘要说明。
    /// </summary>
    public class DataForm1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;
    private Microsoft.Data.Odbc.OdbcConnection odbcConnection1;
    private Microsoft.Data.Odbc.OdbcCommand odbcCommand1;
    private System.Windows.Forms.ListBox listBox1;
    private System.Data.SqlClient.SqlConnection sqlConnection1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public DataForm1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    this.odbcConnection1 = new Microsoft.Data.Odbc.OdbcConnection();
    this.odbcCommand1 = new Microsoft.Data.Odbc.OdbcCommand();
    this.listBox1 = new System.Windows.Forms.ListBox();
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(88, 8);
    this.button1.Name = "button1";
    this.button1.TabIndex = 0;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // odbcConnection1
    // 
    this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
    "ue;user id=ccx99";
    // 
    // odbcCommand1
    // 
    this.odbcCommand1.Connection = this.odbcConnection1;
    // 
    // listBox1
    // 
    this.listBox1.ItemHeight = 12;
    this.listBox1.Location = new System.Drawing.Point(80, 64);
    this.listBox1.Name = "listBox1";
    this.listBox1.Size = new System.Drawing.Size(120, 88);
    this.listBox1.TabIndex = 1;
    // 
    // sqlConnection1
    // 
    this.sqlConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
    "ue;user id=ccx99";
    // 
    // DataForm1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.listBox1,
      this.button1});
    this.Name = "DataForm1";
    this.Text = "DataForm1";
    this.ResumeLayout(false); }
    #endregion private void button1_Click(object sender, System.EventArgs e)
    {
    string sql = "select * from ybwl";
    Microsoft.Data.Odbc.OdbcDataReader r;
    this.odbcCommand1.CommandText = sql;
    this.odbcConnection1.Open();
    //int i = 0;
    //i = this.odbcCommand1.ExecuteNonQuery();
    //MessageBox.Show(i.ToString());
    r = this.odbcCommand1.ExecuteReader();
    MessageBox.Show(r[0].ToString());
    this.odbcConnection1.Close();
    }
    }
    }
      

  4.   

    我建立的ODBC没有问题,在服务器资源管理器上能看到的
    this.odbcConnection1.ConnectionString = "data source=huangbo;initial catalog=gztb;password=1234cc;persist security info=Tr" +
    "ue;user id=ccx99";
    上面语句的data source=??? 是我的ODBC名称吗?