运行ASP.NET项目时显示错误

时间:2018-10-27 17:35:59

标签: c# asp.net .net sql-server database

  

错误:在sys.servers中找不到服务器“系统”。验证   指定了正确的服务器名称。如有必要,执行存储的   过程sp_addlinkedserver将服务器添加到sys.servers。

代码:C#

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

public partial class index : System.Web.UI.Page
{
    string CS = ConfigurationManager.ConnectionStrings["OES"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {

       if(!IsPostBack)
        {
            if(Session["User"]!=null)
            {

            }
            else
            {

            }
        }
    }               
    protected void sortDELL_Click(object sender, EventArgs e)
    {
        using (SqlConnection con = new SqlConnection(CS))
        {
            string SortDell = "select * from ProductDetails where Product_Brand=@DELL";
            using (SqlCommand cmd = new SqlCommand(SortDell, con))
            {
                cmd.Parameters.AddWithValue("@DELL", "DELL");
                SqlDataSource1.SelectCommand = cmd.ToString();
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

            }
        }  
    }

    protected void sortHP_Click(object sender, EventArgs e)
    {

    }

    protected void sortSamsung_Click(object sender, EventArgs e)
    {

    }

    protected void sortOnePlus_Click(object sender, EventArgs e)
    {

    }

    protected void sortOPPO_Click(object sender, EventArgs e)
    {

    }

    protected void sortVIVO_Click(object sender, EventArgs e)
    {

    }

    protected void sortNOKIA_Click(object sender, EventArgs e)
    {

    }

    protected void sortREDMI_Click(object sender, EventArgs e)
    {

    }

    protected void sortMotherboards_Click(object sender, EventArgs e)
    {

    }

    protected void sortRAM_Click(object sender, EventArgs e)
    {

    }

    protected void sortHDD_Click(object sender, EventArgs e)
    {

    }

    protected void sortExternalHardDrive_Click(object sender, EventArgs e)
    {

    }

    protected void sortGraphicsCard_Click(object sender, EventArgs e)
    {

    }

    protected void sortCPUFans_Click(object sender, EventArgs e)
    {

    }

    protected void sortKeyBoard_Click(object sender, EventArgs e)
    {

    }

    protected void sortMouse_Click(object sender, EventArgs e)
    {

    }

    protected void sortUPS_Click(object sender, EventArgs e)
    {

    }

    protected void sortSpeakers_Click(object sender, EventArgs e)
    {

    }

    protected void sortMonitors_Click(object sender, EventArgs e)
    {

    }

    protected void sortCPU_Click(object sender, EventArgs e)
    {

    }

    protected void sortEarphones_Click(object sender, EventArgs e)
    {

    }

    protected void sortHeadPhones_Click(object sender, EventArgs e)
    {

    }

    protected void sortCharger_Click(object sender, EventArgs e)
    {

    }

    protected void sortPowerbanks_Click(object sender, EventArgs e)
    {

    }

    protected void sortUSBCables_Click(object sender, EventArgs e)
    {

    }

    protected void sortOTGCables_Click(object sender, EventArgs e)
    {

    }

    protected void sortSamsungPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortOnePlusPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortRedMIPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortOPPOPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortVIVOPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortNOKIAPH_Click(object sender, EventArgs e)
    {

    }

    protected void sortDellLaptop_Click(object sender, EventArgs e)
    {

    }

    protected void sortHPLaptop_Click(object sender, EventArgs e)
    {

    }
}

当我编写此代码块时:

> protected void sortDELL_Click(object sender, EventArgs e)
>     {
>         using (SqlConnection con = new SqlConnection(CS))
>         {
>             string SortDell = "select * from ProductDetails where Product_Brand=@DELL";
>             using (SqlCommand cmd = new SqlCommand(SortDell, con))
>             {
>                 cmd.Parameters.AddWithValue("@DELL", "DELL");
>                 SqlDataSource1.SelectCommand = cmd.ToString();
>                 con.Open();
>                 cmd.ExecuteNonQuery();
>                 con.Close();
> 
>             }
>         }  
>     }

它显示此错误。错误是什么,您能解决吗?我看了很多次,但是我什么都没得到,请帮忙。

  

注意:我没有使用任何存储过程

0 个答案:

没有答案