A
alva117
Unregistered / Unconfirmed
GUEST, unregistred user!
如题:错误提示如下
在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string strConnection;
string strSQL;
DataSet objDataset = new DataSet();
strConnection = "user id=sa;password=;";
strConnection+="initial catalog=stulogin;data source=mySQLServer;";
strConnection +="Connect Timeout=30";
strSQL="select name sex birthday from studata";
SqlConnection objConnection = new SqlConnection(strConnection);
SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL,objConnection);
[red] objAdapter.Fill(objDataset,"studata"[/red] DataView objDataView = new DataView(objDataset.Tables["studata"]);
GridView1.DataSource = objDataView;
GridView1.DataBind();
}
红色部分出现问题,我毫无头绪,请大家帮帮忙,先谢了
在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string strConnection;
string strSQL;
DataSet objDataset = new DataSet();
strConnection = "user id=sa;password=;";
strConnection+="initial catalog=stulogin;data source=mySQLServer;";
strConnection +="Connect Timeout=30";
strSQL="select name sex birthday from studata";
SqlConnection objConnection = new SqlConnection(strConnection);
SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL,objConnection);
[red] objAdapter.Fill(objDataset,"studata"[/red] DataView objDataView = new DataView(objDataset.Tables["studata"]);
GridView1.DataSource = objDataView;
GridView1.DataBind();
}
红色部分出现问题,我毫无头绪,请大家帮帮忙,先谢了