string connString="";
SqlConnection conn=new SqlConnection(connString);
conn.Open();

解决方案 »

  1.   

    SqlConnection conn=new SqlConnection(@"server=computername;"+"Integrated Security=false;database=Northwind;UID=sa";);
    conn.Open();
      

  2.   

    我以前也是用delphi的 现在用.net在.net里数据库操作当然用ado.net 里面提供有离线数据库 
    ado.net里提供有专门操作sql server的方法 很简单的
      

  3.   

    .NET中各种数据库连接大全 http://www.csdn.net/Develop/read_article.asp?id=16437
      

  4.   

    1:建议你安装一个中文版的MSDN(2003),里面有很详细的连接SqlServer的过程
    2:下载《Ado.net高级编程》,E文,但很容易看懂
    3: google上找 c# "ado.net"
      

  5.   

    建议先自己在Google 或者其它的搜索擎上查一查再问吧
      

  6.   

    eg:
    using System;
    using System.Data;
    using System.Data.SqlClient;
    class data
    {
    public static void Main()
    {
    SqlConnection connection = new SqlConnection(@"uid=sa;pwd=你的sqlserver的密码;server=你的机器的名字;database=Northwind");

         string dbn = connection.Database ;
    string dbs = connection.DataSource ;
    string state = connection.State.ToString ();
    Console.WriteLine (dbn);
        Console.WriteLine (dbs);
    Console.WriteLine (state);
     SqlCommand command ;

    try
    { connection.Open ();
    command = new SqlCommand (@"select City from Employees",connection);
    }
    catch(SqlException sqlEx)
    {
    Console.WriteLine(sqlEx.Message);
    return;
    }
    int r = command.ExecuteNonQuery();
    Console.WriteLine (r);
    SqlCommand command1 = new SqlCommand (@"select City from Employees",connection);
    SqlDataReader d =command1.ExecuteReader();
    while(d.Read ())
    {
    Console.WriteLine(d[0]);
    }
            command1.Dispose ();
    d.Close ();

    Console.ReadLine ();
    }
    }
      

  7.   

    在web.config中配置。
    如:<!--自定义的数据连接-->  
     <appSettings>
    <add key="strConnection" value = "连接字符串"/>
     </appSettings>
    使用:string strConnection = System.Configuration.ConfigurationSettings.AppSettings["strConnection"];