我在下面的代码中得到了错误............“没有给出一个或多个所需参数的值。” [英] I got the error in following code............ "No value given for one or more required parameters."

查看:46
本文介绍了我在下面的代码中得到了错误............“没有给出一个或多个所需参数的值。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//错误是没有给出一个或多个必需参数的值。







// error is "No value given for one or more required parameters."



try
             {
                   string query = "update Birth_Detail_Info set [जन्म नोंदणी]='" + txtNonadniNo.Text + "',[नोंदणी दिनांक]='" + date + "',[जन्म दिनांक]='" + date1 + "',[महसूल क्षेत्र]='" + cmbMahasul.Text + "',[बाळाचे नाव]='" + txtbalacheName.Text + "',लिंग='" + cmbLinga.Text + "',[वडिलांच नाव]='" + txtFatherName.Text + "',[आईचे नाव]='" + txtMotherName.Text + "',[कायमचा पत्ता]='" + txtPamantAdd.Text + "',[जन्म प्रकार]='" + cmbBirthType.Text + "',[जन्म ठिकाण]='" + txtJPlace.Text + "',[वर्दी देणाऱ्याचे नाव]='" + txtInfoName.Text + "',नोंद='" + txtNonda.Text + "',[वर्दी देणाऱ्याचा पत्ता]='" + txtInfoAdd.Text + "',[उपजत मृत्यू]='" + cmbUpjat.Text + "' where [अ क्रं] =" + id.ToString();

                  cmd = new OleDbCommand(query, con);
                  con.Open();
                  cmd.ExecuteNonQuery();
                  DialogResult result = MsgBox.Show("माहिती साठवली आहे", "सुचना", MsgBox.Buttons.OK, MsgBox.Icon.Info, MsgBox.AnimateStyle.FadeIn);
              }
              catch (Exception ex)
              {

                  MessageBox.Show(ex.Message);
              }
              finally
              {
                  con.Close();
              }

推荐答案

问题可能出在数据中,因为您将值直接连接到SQL语句中。不要那样做。而是使用 OleDbParameter [ ^ ]为你的价值观。



这样可以防止SQL注入,括号问题,数据类型转换等。
The problem may be in the data since you concatenate values directly into the SQL statement. Do not do that. Instead use OleDbParameter[^] for your values.

That will keep you safe from SQL injections, problems with parenthesis, data type conversions etc.


这篇关于我在下面的代码中得到了错误............“没有给出一个或多个所需参数的值。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆