我如何连接到Sql? [英] How Do I Connect To The Sql?

查看:87
本文介绍了我如何连接到Sql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace sqlaccess
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           SqlConnection con = new SqlConnection();
           con.Open(); //getting error over here
            SqlCommand cmd=new SqlCommand();
           con.Close();
        }
    }
}

推荐答案

您需要提供连接字符串。在线有大量示例,您还应该参考http://www.connectionstrings.com/
You need to provide a connection string. There are tons of examples online and you should also refer to http://www.connectionstrings.com/


这篇关于我如何连接到Sql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆