'过程或函数'updat'需要参数'@username',这是未提供的。' [英] 'Procedure or function 'updat' expects parameter '@username', which was not supplied.'

查看:112
本文介绍了'过程或函数'updat'需要参数'@username',这是未提供的。'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新我的桌子我想要时间插入特定的行

请帮助我



这里是我的代码哈哈哈PS。我是C的初学者#

I WANT TO UPDATE MY TABLE WERE I WANT THE TIME TO INSERT INTO A SPECIFIC ROW
PLEASE HELP ME

here is my code hahaha PS. IM A BEGINNER at C#

label1.Text = DateTime.Now.ToLongTimeString();

            con.Open();

            SqlCommand cmd = new SqlCommand("Updat", con);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@mode2", "Update");
            cmd.Parameters.AddWithValue("@Timein", label1.Text);
            cmd.Parameters.AddWithValue("@Username", username);
            cmd.ExecuteNonQuery();
            MessageBox.Show("TIMED IN");
       
            con.Close();







这是我的代码存储过程:




HERE IS MY CODE IN STORED PROCEDURE:

CREATE PROCEDURE [dbo].[Updat]
	@mode2 nvarchar(10),
	@Timein varchar(50),
	@Username nvarchar(50)
As
If @mode2 = 'Update'
BEGIN
UPDATE Login1
SET
Username = @Username,
Timein = @Timein
END





我尝试过:



i不知道该怎么做

i不知道该怎么做

i不知道该怎么做

i不知道该怎么做

i不知道该怎么做

i不知道该怎么做

i不知道该怎么办

i不知道该怎么办

i不知道该怎么办

i不知道是什么to doooo



What I have tried:

i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo
i don't know what to doooo

推荐答案

引用:

我不知道该怎么做



阅读错误信息和你的代码!

你被告知'过程或函数'updat'需要参数' @username ',这是没有提供的。'

这意味着


Read the error message and your code!
You are told that 'Procedure or function 'updat' expects parameter '@username', which was not supplied.'
which means that

CREATE PROCEDURE [dbo].[Updat]
@mode2 nvarchar(10),
@Timein varchar(50),
@Username nvarchar(50) -- THIS PARAMETER here
As
If @mode2 = 'Update'
BEGIN
UPDATE Login1
SET
Username = @Username, -- THIS PARAMETER here
Timein = @Timein
END



没有价值,因为它没有在调用代码中提供。



我们无能为力,因为我们不知道你想做什么。 br />
确保没有从缺少参数的其他地方调用该过程。


have no value because it is not provided in calling code.

We can't do anything because we don't know what you want to do.
make sure the procedure is not called from another place where the parameter is missing.


使用调试器,你可能会在这里找到:

Use the debugger, and you will probably find that right here:
cmd.Parameters.AddWithValue("@Username", username);

用户名变量包含 null



现在,你必须找出原因 - 所以使用调试器并追溯你的代码,找出你希望在其中放置一个值的位置。

这是什么价值?它来自哪里?为什么没有这个值?



这需要应用程序运行,所以你可以使用调试器找到它 - 我们做不到因为我们无法运行你的代码!

The username variable contains null.

So now, you have to find out why - so use the debugger and track back through your code to find out where you expect a value to be put in it.
What value is that? Where does that come from? Why doesn't that have a value?

This needs the app to be running, so you can use the debugger to find this out - we can't do that for you because we can't run your code!


现有的答案让你清楚地知道你可能面临的问题的原因。先调查一下。 [查看@username参数]



另一种可能性:



你的代码实际看起来很好(如果@username没有任何问题)



既然你说你是初学者,我怀疑你可能有机会忽略了构建或配置。



- 检查你是否已连接到正确的数据库(这将在web.config中的连接字符串中)



- 检查你是否正确构建了项目并运行了正确的版本。



我建议你使用调试器来挖掘陷入错误。它将帮助您找到问题的根本原因并最终解决问题。
The existing answers give you pretty clear idea of what could be possibly the reason for the issue you are facing. Investigate it first. [check the @username parameter]

Another possibility:

Your code actually looks fine (if there isn't any issue with @username)

Since you say you are a beginner, I suspect there may be chances that you could have overlooked the build or configurations.

- Check if you have connected to the right database (this will be in your connection string in web.config)

- Check if you have built the project right and running the right version.

I would suggest you use debugger to dig into the error. It will help you locate the root-cause of the issue and eventually, solve it.


这篇关于'过程或函数'updat'需要参数'@username',这是未提供的。'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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