我做的是一个关于个人助理的项目
要求 
项目中的文本文档的数据用数据库连接
以前做的是控制台应用程序 用的文本文档读取
现在老师要求用数据库来解决这个问题

解决方案 »

  1.   

    string ConnectionString = "server=.;database=数据库;uid=帐号;pwd=密码;"
    try
    {
       SqlConnection con=new SqlConnection(ConnectionString);
       con.Open();
       if(con.State!=ConnectionState.Open)
       {
          //连接失败
       }
    }catch()
    {
       //连接失败
    }网上大把
      

  2.   

    看看ADO.NET,多看多用就会了http://developer.51cto.com/art/200911/162919.htm
      

  3.   

    http://www.builder.com.cn/2008/0430/842032.shtml
      

  4.   


    try
    {
       SqlConnection con=new SqlConnection("server=.;database=数据库;uid=帐号;pwd=密码");
       con.Open();
       if(con.State!=ConnectionState.Open)
       {
          //连接成功
           //在这里进行数据操作
       }
    }catch()
    {
       //连接失败
        //抛出异常
    }
      

  5.   

    大哥 别Copy我的 ;if(con.State!=ConnectionState.Open) 这句连接成功???