顶!我也碰到同样的问题
data source是指数据库名

解决方案 »

  1.   

    datasource指的是数据名字,也就是你所用的SQL数据服务器的名字
      

  2.   

    "Data Source=server;Database=mydb;User ID=username;Password=pwd;Command Logging=false" see www.connectionstrings.com
      

  3.   

    估计是你的连接符串写错了.连接字符串中的datasource指的是数据库.下面是几下相关mysql的贴子
    http://community.csdn.net/Expert/topic/3121/3121364.xml?temp=7.302493E-02
      

  4.   

    我有个程序,发给你们看看吧,差不多的结果:
    using System.Data.SqlClient;public class DataReaderSql
    {
      public static int Main(string[] args)
      {
        string        source =“data source=(local);initial catalog=Northwind;integrated security=SSPI;”;    string        select = "SELECT ContactName,CompanyName FROM Customers" ;    SqlConnection conn = new SqlConnection ( source ) ;    try
        {
          using ( conn )
          {
            conn.Open ( ) ;        SqlCommand    cmd = new SqlCommand ( select , conn ) ;        using ( SqlDataReader aReader = cmd.ExecuteReader ( ) )
            {
              while ( aReader.Read ( ) )
                Console.WriteLine ( "'{0}' from {1}" , aReader.GetString(0) , aReader.GetString ( 1 ) ) ;          aReader.Close ( ) ;
            }        conn.Close ( ) ;
          }
        }
        catch ( Exception e )
        {
          Console.WriteLine ( e ) ;
          Console.WriteLine ( ) ;
          Console.WriteLine ( "Chances are your database does not have a user" ) ;
          Console.WriteLine ( "called QSUser, or you do not have the NetSDK database installed." ) ;
        }    return 0;
      }
    }
    其中datasource后表示为默认本地服务器
      

  5.   

    我的连接串就是从微软那个地方贴过来的啊,
    用这个"Data Source=server;Database=mydb;User ID=username;Password=pwd;Command Logging=false" 也不行
      

  6.   

    连结c#连结mysql
    应该是这样的
    MySQLDriverCS.MySQLConnection conn = new MySQLDriverCS.MySQLConnection (new MySQLDriverCS.MySQLConnectionString("127.0.0.1",database,use id,password).AsString);
    例如
    MySQLDriverCS.MySQLConnection conn = new MySQLDriverCS.MySQLConnection (new MySQLDriverCS.MySQLConnectionString("localhost","test","root","").AsString);
    这样就可以连上数据库