如题,我的数据源的驱动是:INFORMIX-CLI 2.5 (32 bit)
连接字符串我是这样写的:
dri = "{INFORMIX-CLI 2.5 (32 bit)}";
dsn = "hndb"
db = "hndb"
userid = "test"
passwd = "test"string strConn;
strConn = "Driver="+dri+";Server="+dsn+";Database="+db+";Uid="+userid+";Pwd="+passwd;请问我的写法哪里有问题?总是连接不上数据库,请大家帮帮忙!非常谢谢。

解决方案 »

  1.   

    http://www.connectionstrings.com/
    http://dev.csdn.net/develop/article/24/24968.shtm
      

  2.   

    MARK , 以前,我不会的时候,我都是用ODBC 生成,然后再更改关键字
      

  3.   

    Informix-CLI 2.5:
    "Driver={Informix-CLI 2.5 (32 Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd" 
     现在要确定每一项填的都对就行了~~~~~
      

  4.   

    http://www.connectionstrings.com/
    呵呵,
      

  5.   

    我照着http://www.connectionstrings.com/上说的做还是连不上数据库,
    用zhongwanli说的办法改关键字也同样连不上,
    在取数据的时候总是说该列没有数据,但是我写的SQL语句绝对可以取到数据的,
    string strSql = "select opername from operator where operno='IT001'";
    我设置断点检测odbcConnection.DataBase总是空值是不是问题出在odbcConnection.connectString上,因为它不能获取密码,即使在给定的连接字符串里有密码也没有用,但是连接数据库是要密码的
      

  6.   

    Server是数据库服务器的实例名,DataBase是数据源的名称
    Driver={Driver Name};Server=DBServerName;Database=ODBCName;
    前提是你先要将数据源配好,测试中能连接数据库
      

  7.   

    我的测试连接是成功的
    我跟踪调试过strConn的值,在调用odbcConnect.open()函数前,strConn包含密码字段,但是一旦调用open函数,就少了密码字段,所以我怀疑问题出在这里,或许是其他我预想不到的问题。
      

  8.   

    用啥ODBC,这个不好吗?
    protected OleDbConnection Connection;
    private static string connectionString;
    private string ServerName ;
    private string UserName;
    private string UserPsw;
    public DbObject()
    {
                LoginConnect LoginConnect=new LoginConnect();
                ServerName=LoginConnect.GetConnectInf("SqlServer","databasename");
                UserName=LoginConnect.GetConnectInf("SqlServer","UserID");
                UserPsw=LoginConnect.GetConnectInf("SqlServer","Password");
    connectionString ="Provider=sqloledb;Data Source="+ServerName+";Initial Catalog=MesDb;User Id="+UserName+";Password="+UserPsw+";";
    Connection = new OleDbConnection( connectionString );
    }
      

  9.   

    楼上的,你说的是SQL SERVER数据库,楼主说的是informix数据库,他们的连接字符串是不同的,问题是规则不同。
      

  10.   

    请问版主,我揭的帖为什么看不到分发给上面几位大哥的分数?是不是系统有问题,现在登录也好慢的。
    大家可不要认为我不讲信用,我是给每位发了10分的,其中前两位15分,最后一位20分,我自己顶的0分。我再次发的帖是
    http://community.csdn.net/Expert/topic/4237/4237431.xml?temp=.9477655