小编Rio*_*phy的帖子

SQL Server错误,'不支持关键字'数据源'

我目前正在尝试将一些值插入到数据源中,然后使用DataList控件将它们显示在另一个页面上.然而,经过一些测试和实验,我发现错误来自一开始.

这是我绑定到按钮的代码.

protected void btnSend_Click(object sender, EventArgs e)
    {
    Page.Validate("vld2");
    SendMail();
    lblMsgSend.Visible = true;
    txtPhone.Text = "";
    txtEmail.Text = "";
    txtName.Text = "";
    txtComment.Text = "";

    //SQL Server Database
    SqlConnection conn; //manages connection to database
    SqlCommand cmd; //manages the SQL statements
    string strInsert; //SQL INSERT Statement
        try
        {
            //create a connection object
            conn = new SqlConnection("DataSource=localhost\\sqlexpress;" +
                                     "Initial Catalog=RionServer;" +
                                     "Integrated Security=True;");
            //Build the SQL INSERT Document
            strInsert = "INSERT INTO CommentsAdmin (Name,Phone,Email,Comments)"
                + "VALUES(@Name,@Phone,@Email,@Comments);";
            //associate the INSERT statement with …
Run Code Online (Sandbox Code Playgroud)

c# database asp.net datasource sql-server-2008

0
推荐指数
1
解决办法
4245
查看次数

标签 统计

asp.net ×1

c# ×1

database ×1

datasource ×1

sql-server-2008 ×1