日期:2014-05-17  浏览次数:21131 次

c#怎么调用SQL SERVER
写一个WINDOWS窗体,类似于注册账号密码的功能,把账号密码存进数据库,C#怎么链接到数据库?

------解决方案--------------------
我能讲脏话吗?
        /// <summary>
        /// 执行查询语句,返回DataSet
        /// </summary>
        /// <param name="SQLString">查询语句</param>
        /// <returns>DataSet</returns>
        public static DataSet Query(string SQLString)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DataSet ds = new DataSet();
                try
                {
                    connection.Open();
                    SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
                    command.Fill(ds, "ds");
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
                return ds;
            }
        }

------解决方案--------------------
引用:
   string strConnection = "user id=sq_jn_xmwxt;password=sq_jn_xmwxtqqqq;";
            strConnection += "database=sq_jn_xmwxt;Server=183.60.156.217;";
            strConnection += "Connect Timeout=30";
            SqlConnection Con = new SqlConnection(s