IM使用VS2010和我已經嘗試了所有最近我可能的方式來連接與VisualStudio的數據庫plz幫助我繼承人的代碼SQL連接問題asp.net
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cs = new SqlConnection("Data Source=Sql Server(SQLEXPRESS); Initial Catalog=school");
cs.Open();
MessageBox.Show(cs.State.ToString());
cs.Close();
}
}
}
它不選擇Connet,給錯誤: 建立到SQL Server的連接時發生網絡相關或實例特定的錯誤。服務器未找到或無法訪問。驗證實例名稱是否正確,並將SQL Server配置爲允許遠程連接。 (provider:命名管道提供程序,error:40 - 無法打開到SQL Server的連接)
幫助
你得到的異常確切說做什麼。檢查你的SQL服務器的實例名稱,檢查你的連接字符串等 – Mariusz 2010-12-02 18:06:17