请教高手,为什么C#版的ADO连不上SQL2000????
当我想把一些信息添加到students表中时,出现:“在建立与服务器的连接时出错,在连接到SQL 2005时,在默认的设置下SQL Server不允许进行远程连接可能会导致此失败。(provide:命名管道提供程序,error:40-无法打开到SQL Server的连接)” 这种信息,,,,,
我的代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace liu6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//连接类
SqlConnection sCon = new SqlConnection("Data Source=Data Source=(local);Initial Catalog=liuyang;Integrated Security=SSPI");
//命令类
SqlCommand sCom = new SqlCommand();
sCom.Connection = sCon;
sCom.CommandText = "Insert into students(学号,姓名,姓别, 身份证,入学日期,入学年龄) values('"+textBox1.Text.ToString()+"','"+textBox2.Text.ToString()+"','"+comboBox1.SelectedText.ToString()+"','"+textBox4.Text.ToString()+"',"+comboBox2.SelectedText.ToString()+",'"+textBox6.Text.ToString()+"')";
sCom.CommandType = CommandType.Text;
try
{
sCon.Open();
sCom.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sCon.Close();
}
}
}
}