没有给出一个或多个必需参数的值 [英] No value given for one or more required parameters

查看:71
本文介绍了没有给出一个或多个必需参数的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



没有给出一个或多个必需参数的值。

描述:执行

当前网站时发生了未处理的异常请求。请查看堆栈跟踪以获取更多信息

有关错误及其在代码中的起源。


异常详细信息:System.Data.OleDb.OleDbException:没有给出一个

或更多必需参数的值。


来源错误:


第68行:

第69行:myCommand.Connection.Open();

第70行:myCommand.ExecuteNonQuery();




我有一个问题没有给出一个或多个必需参数的值

错误。


我正在使用OleDb连接,C#和ASP.NET


我使用了编辑控件(txtID,txtLName)...


代码如下:

....

String insertCmd =" insert into Authors(au_id,au_lname,au_fname,phone,

address,city,state,zip,contract)value (@ Id,@ LName,@ FName,@ Phone,

@Address,@ City,@ State,@ Zip,@ Contract)" ;;


OleDbCommand myCommand = new O. leDbCommand(insertCmd,thisConnection);


myCommand.Parameters.Add(new OleDbParameter(" @ Id",OleDbType.VarChar,11));


myCommand.Parameters [" @ Id"]。Value = txtID.Text;

/*Server.HtmlEncode(txtID.Text);*/


myCommand.Parameters.Add(新的OleDbParameter(" @LName",OleDbType.VarChar,

40));


myCommand.Parameters [" @LName"]。Value = txtLName.Text; / *

Server.HtmlEncode(txtLName.Text); * /

myCommand.Connection.Open();


myCommand.ExecuteNonQuery();


我是不知道出了什么问题以及为什么会出现这个错误?


谢谢


No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one
or more required parameters.

Source Error:

Line 68:
Line 69: myCommand.Connection.Open();
Line 70: myCommand.ExecuteNonQuery();
Hi,

I have one problem with No value given for one or more required parameters
error.

I am using OleDb connection, C# and ASP.NET

I have used Edit controls (txtID, txtLName)...

Code is following:
....
String insertCmd = "insert into Authors (au_id, au_lname, au_fname, phone,
address, city, state, zip, contract) values (@Id, @LName, @FName, @Phone,
@Address, @City, @State, @Zip, @Contract)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);

myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar, 11));

myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));

myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */
myCommand.Connection.Open();

myCommand.ExecuteNonQuery();

I am not sure what is wrong and why this error has occured?

Thanks

推荐答案

mp< pl ****@volja.net>写道:
mp <pl****@volja.net> wrote:
没有给出一个或多个必需参数的值。
描述:执行
当前Web请求期间发生了未处理的异常。有关错误及其在代码中的起源,请查看堆栈跟踪以获取更多信息。


< snip>

代码如下:
...
String insertCmd =" insert into Authors(au_id, au_lname,au_fname,phone,
地址,城市,州,邮政编码,合同)值(@ Id,@ LName,@ FName,@ Phone,
@ Address,@ City,@ State,@ Zip, @Contract)" ;;

OleDbCommand myCommand = new OleDbCommand(insertCmd,thisConnection);

myCommand.Parameters.Add(new OleDbParameter(" @ Id",OleDbType。 VarChar,11));

myCommand.Parameters [" @ Id"]。Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter(" @LName",OleDbType.VarChar,
40));

myCommand.Parameters [" @LName" ] .Value = txtLName.Text; / *
Server.HtmlEncode(txtLName.Text); * /

myCommand.Connection.Open();

myCommand.ExecuteNonQuery();
No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
<snip>
Code is following:
...
String insertCmd = "insert into Authors (au_id, au_lname, au_fname, phone,
address, city, state, zip, contract) values (@Id, @LName, @FName, @Phone,
@Address, @City, @State, @Zip, @Contract)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);

myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar, 11));

myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));

myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */
myCommand.Connection.Open();

myCommand.ExecuteNonQuery();




嗯,您已在查询中指定了9个参数,并且仅为其中2个填写了

值。你对其他7个人的期望是什么?


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



Well, you''ve specified 9 parameters in the query, and only filled in
values for 2 of them. What did you expect to happen about the other 7?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


谢谢Jon。

我明白了,但看看这个。 />
当我使用下面的代码行

String insertCmd =" insert into Authors(au_id,au_lname)values(@Id,

@LName) " ;;


OleDbCommand myCommand = new OleDbCommand(insertCmd,thisConnection);


myCommand.Parameters.Add(new OleDbParameter(" @) Id",OleDbType.VarChar,11));


myCommand.Parameters [" @ Id"]。Value = txtID.Text;

/ * Server.HtmlEncode(txtID.Text); * /


myCommand.Parameters.Add(new OleDbParameter(" @LName",OleDbType.VarChar,

) 40));


myCommand.Parameter s [" @LName"]。Value = txtLName.Text; / *

Server.HtmlEncode(txtLName.Text); * /

myCommand.Connection.Open();


myCommand.ExecuteNonQuery();


错误是:


操作必须使用可更新的查询。

描述:执行

当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取更多信息

有关错误及其在代码中的起源。


异常详细信息:System.Data.OleDb.OleDbException:操作必须使用

可更新查询。


为什么此查询不可更新?


谢谢



" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道

新闻:MP ************************ @ msnews.microsoft.c om ...
Thanks Jon.
I understand but look this.
When i use following line of code
String insertCmd = "insert into Authors (au_id, au_lname) values (@Id,
@LName)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);

myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar, 11));

myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));

myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */
myCommand.Connection.Open();

myCommand.ExecuteNonQuery();

Error is:

Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.

Why this query is not updateable?

Thanks


"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
mp< pl **** @ volja.net>写道:
mp <pl****@volja.net> wrote:
没有给出一个或多个必需参数的值。
描述:执行
当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取更多信息
有关错误及其在代码中的起源。
No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.



< snip>



<snip>

代码如下:
...
字符串insertCmd ="插入作者(au_id,au_lname,au_fname,
电话,地址,城市,州,邮编,合同)值(@ Id,@ LName,@ FName,
@Phone,@ Address,@ City,@ State,@ Zip,@ COLLract)" ;;

OleDbCommand myCommand = new OleDbCommand(insertCmd,thisConnection) );

myCommand.Parameters.Add(new OleDbParameter(" @ Id",OleDbType.VarChar,
11));
myCommand.Parameters [" @ Id" ] .Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter(" @LName",OleDbType。 VarChar,
40));

myCommand.Parameters [" @LName"]。Value = txtLName.Text; / *
Server.HtmlEncode(txtLName.Text); * /

myCommand.Connection.Open();

myCommand.ExecuteNonQuery();
Code is following:
...
String insertCmd = "insert into Authors (au_id, au_lname, au_fname, phone, address, city, state, zip, contract) values (@Id, @LName, @FName, @Phone, @Address, @City, @State, @Zip, @Contract)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);

myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar, 11));
myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));

myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */
myCommand.Connection.Open();

myCommand.ExecuteNonQuery();



嗯,你已经在查询中指定了9个参数,并且只填写了其中2个的值。你对其他7个人的期望是什么?

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请做不要给我发邮件



Well, you''ve specified 9 parameters in the query, and only filled in
values for 2 of them. What did you expect to happen about the other 7?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



mp< pl **** @ volja.net>写道:


< snip>
mp <pl****@volja.net> wrote:

<snip>
错误是:

操作必须使用可更新的查询。说明:执行
当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取更多信息
有关错误及其在代码中的起源。

异常详细信息:System.Data.OleDb.OleDbException:操作必须使用
可更新的查询。

为什么这个查询不可更新?
Error is:

Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.

Why this query is not updateable?




从网上的一些简单挖掘中,可能出现这样的错误with:


o假冒

o网络访问

o只读文件


你的情况到底是什么?你在说什么样的数据库

到?是本地的还是远程的?


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



From a bit of brief digging on the web, that error could be to do with:

o Impersonation
o Network access
o A read-only file

What exactly is your situation? What kind of database are you talking
to? Is it local or remote?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于没有给出一个或多个必需参数的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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