Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# &引用;类型为';的未处理异常;System.Data.SqlClient.SqlException';发生在System.Data.dll中;将文本框值插入SQL数据库时_C#_.net_Sql Server_Visual Studio - Fatal编程技术网

C# &引用;类型为';的未处理异常;System.Data.SqlClient.SqlException';发生在System.Data.dll中;将文本框值插入SQL数据库时

C# &引用;类型为';的未处理异常;System.Data.SqlClient.SqlException';发生在System.Data.dll中;将文本框值插入SQL数据库时,c#,.net,sql-server,visual-studio,C#,.net,Sql Server,Visual Studio,我完全不知道C#在试图将用户输入到各种文本框中的值插入SQL数据库中。具体来说,我正在创建一个帐户创建页面。在调试并将值插入文本框/数据库时,我遇到了上述错误 其他信息包括 “@pword”附近的语法不正确 如果需要任何其他信息,我可以提供 private void button1_Click(object sender, EventArgs e) { SqlConnection connection = new SqlConnection("Data Sourc

我完全不知道C#在试图将用户输入到各种文本框中的值插入SQL数据库中。具体来说,我正在创建一个帐户创建页面。在调试并将值插入文本框/数据库时,我遇到了上述错误

其他信息包括

“@pword”附近的语法不正确

如果需要任何其他信息,我可以提供

    private void button1_Click(object sender, EventArgs e)
    {
        SqlConnection connection = new SqlConnection("Data Source=DESKTOP-P3JSE1C;Initial Catalog=logins;Integrated Security=True");
        {

            SqlCommand ins = new SqlCommand("Insert into Users(userid, fullName, username, email, pword) Values(@userid, @fullName, @username, @email, @pword", connection) ;

            ins.Parameters.AddWithValue("@userid", textBox1.Text);
            ins.Parameters.AddWithValue("@fullName", textBox2.Text);
            ins.Parameters.AddWithValue("@username", textBox3.Text);
            ins.Parameters.AddWithValue("@email", textBox4.Text);
            ins.Parameters.AddWithValue("@pword", textBox5.Text);

            connection.Open();
            ins.ExecuteNonQuery();
            connection.Close();
    }
}

@pwords后面缺少结束符,除了缺少结束括号之外。我假设的userid列是主键?如果是,则不应在文本框中输入。它应该由系统分配。