473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Typed Dataset with Update SPROC

I used the wizard to generate a typed dataset for my table and let it create
my SPROCs. It created everything, and the GetData() method and the custom
GetByUserName query works great, but when I try to call the Update() method
of my TableAdapter, I get the following:

"Procedure 'stp_SecurityUsers_Update' expects parameter '@userName', which
was not supplied."

@userName happens to be the first param in the SPROC. Here is the SPROC
that VS2005 generated for me:

<-- start SPROC -->

CREATE PROCEDURE stp_SecurityUsers_Update
(
@userName varchar(15),
@lastName varchar(50),
@firstName varchar(50),
@email varchar(50),
@password varchar(50),
@dateAdded datetime,
@lastLogin datetime,
@status bit,
@pwdExpired bit,
@lastPasswordChange datetime,
@Original_userID int,
@Original_userName varchar(15),
@IsNull_lastName varchar(50),
@Original_lastName varchar(50),
@IsNull_firstName varchar(50),
@Original_firstName varchar(50),
@IsNull_email varchar(50),
@Original_email varchar(50),
@IsNull_password varchar(50),
@Original_password varchar(50),
@IsNull_dateAdded datetime,
@Original_dateAdded datetime,
@IsNull_lastLogin datetime,
@Original_lastLogin datetime,
@IsNull_status bit,
@Original_status bit,
@IsNull_pwdExpired bit,
@Original_pwdExpired bit,
@IsNull_lastPasswordChange datetime,
@Original_lastPasswordChange datetime,
@userID int
)
AS
SET NOCOUNT OFF;
UPDATE [dbo].[tb_SecurityUsers] SET [userName] = @userName, [lastName] =
@lastName, [firstName] = @firstName, = @email, [password] = @password,
[dateAdded] = @dateAdded, [lastLogin] = @lastLogin, [status] = @status,
[pwdExpired] = @pwdExpired, [lastPasswordChange] = @lastPasswordChange WHERE
(([userID] = @Original_userID) AND ([userName] = @Original_userName) AND
((@IsNull_lastName = 1 AND [lastName] IS NULL) OR ([lastName] =
@Original_lastName)) AND ((@IsNull_firstName = 1 AND [firstName] IS NULL) OR
([firstName] = @Original_firstName)) AND ((@IsNull_email = 1 AND IS NULL) OR
( = @Original_email)) AND ((@IsNull_password = 1 AND [password] IS NULL) OR
([password] = @Original_password)) AND ((@IsNull_dateAdded = 1 AND
[dateAdded] IS NULL) OR ([dateAdded] = @Original_dateAdded)) AND
((@IsNull_lastLogin = 1 AND [lastLogin] IS NULL) OR ([lastLogin] =
@Original_lastLogin)) AND ((@IsNull_status = 1 AND [status] IS NULL) OR
([status] = @Original_status)) AND ((@IsNull_pwdExpired = 1 AND [pwdExpired]
IS NULL) OR ([pwdExpired] = @Original_pwdExpired)) AND
((@IsNull_lastPasswordChange = 1 AND [lastPasswordChange] IS NULL) OR
([lastPasswordChange] = @Original_lastPasswordChange)));
<!--end SPROC-->

Here is the code used to try to update a user's record with a new password:

1 public static bool SetPassword(string userName, string hashedPassword)
2 {
3 bool success = false;
4
5 SecurityUsersTableAdapter taUsers = new
SecurityUsersTableAdapter();
6
7 SecurityUsers.SecurityUsersDataTable dtUsers =
taUsers.GetByUserName(userName);
8
9 if (dtUsers.Rows.Count != 0)
10 {
11 dtUsers[0].password = hashedPassword;
12
13 try
14 {
15 taUsers.Update(dtUsers);
16
17 success = true;
18 }
19 catch
20 {
21 //
22 }
23 }
24
25 return success;
26 }

The exception occurs on line 15 above. I have looked through the
SecurityUsers.Designer.cs file created by VS, and I can find the methods;
I'm not a C# expert, but nothing jumped out at me as to why this would be
happening.

I thought that VS kindly generated what was needed to map the parameters and
pass them with the method(s) it creates. If I add "= NULL" to all params in
the SPROC, the error goes away, but nothing gets updated. The Update method
is not passing the variables via the datatable, and I don't know where to
look to try to troubleshoot this. Can anyone help?
Jul 12 '07 #1
5 3038
SPROC is expecting a datarow parameter. The sample is sending a datatable.
Jul 13 '07 #2
Thanks for the reply.

I figured this out recently, just haven't been back to post the solution.
The table adapter wizard did not map my source columns to the sproc
parameters. This is why I hate doing things visually.

(Actually, the Update() method can take a datatable or datarow parameter)


"Nick" wrote:
SPROC is expecting a datarow parameter. The sample is sending a datatable.
Jul 13 '07 #3
So now my new problem. The error (below in original post) is resolved, but
using the same code, I am now getting the following when calling the Update()
method:

"Failed to convert parameter value from a Int32 to DateTime"

I'm researching this, but if anyone has any ideas, I'm all ears. I've
looked at this for so long, I have no objectivity. The only variable that is
Int32 is the userID parameter and column. The SPROC and method stub for
Update() is all referencing the correct data types.

Thanks,
Rparker

"RParker" wrote:
I used the wizard to generate a typed dataset for my table and let it create
my SPROCs. It created everything, and the GetData() method and the custom
GetByUserName query works great, but when I try to call the Update() method
of my TableAdapter, I get the following:

"Procedure 'stp_SecurityUsers_Update' expects parameter '@userName', which
was not supplied."

@userName happens to be the first param in the SPROC. Here is the SPROC
that VS2005 generated for me:

<-- start SPROC -->

CREATE PROCEDURE stp_SecurityUsers_Update
(
@userName varchar(15),
@lastName varchar(50),
@firstName varchar(50),
@email varchar(50),
@password varchar(50),
@dateAdded datetime,
@lastLogin datetime,
@status bit,
@pwdExpired bit,
@lastPasswordChange datetime,
@Original_userID int,
@Original_userName varchar(15),
@IsNull_lastName varchar(50),
@Original_lastName varchar(50),
@IsNull_firstName varchar(50),
@Original_firstName varchar(50),
@IsNull_email varchar(50),
@Original_email varchar(50),
@IsNull_password varchar(50),
@Original_password varchar(50),
@IsNull_dateAdded datetime,
@Original_dateAdded datetime,
@IsNull_lastLogin datetime,
@Original_lastLogin datetime,
@IsNull_status bit,
@Original_status bit,
@IsNull_pwdExpired bit,
@Original_pwdExpired bit,
@IsNull_lastPasswordChange datetime,
@Original_lastPasswordChange datetime,
@userID int
)
AS
SET NOCOUNT OFF;
UPDATE [dbo].[tb_SecurityUsers] SET [userName] = @userName, [lastName] =
@lastName, [firstName] = @firstName, = @email, [password] = @password,
[dateAdded] = @dateAdded, [lastLogin] = @lastLogin, [status] = @status,
[pwdExpired] = @pwdExpired, [lastPasswordChange] = @lastPasswordChange WHERE
(([userID] = @Original_userID) AND ([userName] = @Original_userName) AND
((@IsNull_lastName = 1 AND [lastName] IS NULL) OR ([lastName] =
@Original_lastName)) AND ((@IsNull_firstName = 1 AND [firstName] IS NULL) OR
([firstName] = @Original_firstName)) AND ((@IsNull_email = 1 AND IS NULL) OR
( = @Original_email)) AND ((@IsNull_password = 1 AND [password] IS NULL) OR
([password] = @Original_password)) AND ((@IsNull_dateAdded = 1 AND
[dateAdded] IS NULL) OR ([dateAdded] = @Original_dateAdded)) AND
((@IsNull_lastLogin = 1 AND [lastLogin] IS NULL) OR ([lastLogin] =
@Original_lastLogin)) AND ((@IsNull_status = 1 AND [status] IS NULL) OR
([status] = @Original_status)) AND ((@IsNull_pwdExpired = 1 AND [pwdExpired]
IS NULL) OR ([pwdExpired] = @Original_pwdExpired)) AND
((@IsNull_lastPasswordChange = 1 AND [lastPasswordChange] IS NULL) OR
([lastPasswordChange] = @Original_lastPasswordChange)));
<!--end SPROC-->

Here is the code used to try to update a user's record with a new password:

1 public static bool SetPassword(string userName, string hashedPassword)
2 {
3 bool success = false;
4
5 SecurityUsersTableAdapter taUsers = new
SecurityUsersTableAdapter();
6
7 SecurityUsers.SecurityUsersDataTable dtUsers =
taUsers.GetByUserName(userName);
8
9 if (dtUsers.Rows.Count != 0)
10 {
11 dtUsers[0].password = hashedPassword;
12
13 try
14 {
15 taUsers.Update(dtUsers);
16
17 success = true;
18 }
19 catch
20 {
21 //
22 }
23 }
24
25 return success;
26 }

The exception occurs on line 15 above. I have looked through the
SecurityUsers.Designer.cs file created by VS, and I can find the methods;
I'm not a C# expert, but nothing jumped out at me as to why this would be
happening.

I thought that VS kindly generated what was needed to map the parameters and
pass them with the method(s) it creates. If I add "= NULL" to all params in
the SPROC, the error goes away, but nothing gets updated. The Update method
is not passing the variables via the datatable, and I don't know where to
look to try to troubleshoot this. Can anyone help?
Jul 13 '07 #4
On Jul 13, 11:24 am, RParker <RPar...@discussions.microsoft.com>
wrote:
So now my new problem. The error (below in original post) is resolved, but
using the same code, I am now getting the following when calling the Update()
method:

"Failedtoconvertparametervaluefrom aInt32toDateTime"

I'm researching this, but if anyone has any ideas, I'm all ears. I've
looked at this for so long, I have no objectivity. The only variable that isInt32is the userIDparameterand column. The SPROC and method stub for
Update() is all referencing the correct data types.

Thanks,
Rparker

"RParker" wrote:
I used the wizard to generate a typed dataset for my table and let it create
my SPROCs. It created everything, and the GetData() method and the custom
GetByUserName query works great, but when I try to call the Update() method
of my TableAdapter, I get the following:
"Procedure 'stp_SecurityUsers_Update' expectsparameter'@userName', which
was not supplied."
@userName happens to be the first param in the SPROC. Here is the SPROC
that VS2005 generated for me:
<-- start SPROC -->
CREATE PROCEDURE stp_SecurityUsers_Update
(
@userName varchar(15),
@lastName varchar(50),
@firstName varchar(50),
@email varchar(50),
@password varchar(50),
@dateAddeddatetime,
@lastLogindatetime,
@status bit,
@pwdExpired bit,
@lastPasswordChangedatetime,
@Original_userID int,
@Original_userName varchar(15),
@IsNull_lastName varchar(50),
@Original_lastName varchar(50),
@IsNull_firstName varchar(50),
@Original_firstName varchar(50),
@IsNull_email varchar(50),
@Original_email varchar(50),
@IsNull_password varchar(50),
@Original_password varchar(50),
@IsNull_dateAddeddatetime,
@Original_dateAddeddatetime,
@IsNull_lastLogindatetime,
@Original_lastLogindatetime,
@IsNull_status bit,
@Original_status bit,
@IsNull_pwdExpired bit,
@Original_pwdExpired bit,
@IsNull_lastPasswordChangedatetime,
@Original_lastPasswordChangedatetime,
@userID int
)
AS
SET NOCOUNT OFF;
UPDATE [dbo].[tb_SecurityUsers] SET [userName] = @userName, [lastName] =
@lastName, [firstName] = @firstName, = @email, [password] = @password,
[dateAdded] = @dateAdded, [lastLogin] = @lastLogin, [status] = @status,
[pwdExpired] = @pwdExpired, [lastPasswordChange] = @lastPasswordChange WHERE
(([userID] = @Original_userID) AND ([userName] = @Original_userName) AND
((@IsNull_lastName = 1 AND [lastName] IS NULL) OR ([lastName] =
@Original_lastName)) AND ((@IsNull_firstName = 1 AND [firstName] IS NULL) OR
([firstName] = @Original_firstName)) AND ((@IsNull_email = 1 AND IS NULL) OR
( = @Original_email)) AND ((@IsNull_password = 1 AND [password] IS NULL) OR
([password] = @Original_password)) AND ((@IsNull_dateAdded = 1 AND
[dateAdded] IS NULL) OR ([dateAdded] = @Original_dateAdded)) AND
((@IsNull_lastLogin = 1 AND [lastLogin] IS NULL) OR ([lastLogin] =
@Original_lastLogin)) AND ((@IsNull_status = 1 AND [status] IS NULL) OR
([status] = @Original_status)) AND ((@IsNull_pwdExpired = 1 AND [pwdExpired]
IS NULL) OR ([pwdExpired] = @Original_pwdExpired)) AND
((@IsNull_lastPasswordChange = 1 AND [lastPasswordChange] IS NULL) OR
([lastPasswordChange] = @Original_lastPasswordChange)));
<!--end SPROC-->
Here is the code used to try to update a user's record with a new password:
1 public static bool SetPassword(string userName, string hashedPassword)
2 {
3 bool success = false;
4
5 SecurityUsersTableAdapter taUsers = new
SecurityUsersTableAdapter();
6
7 SecurityUsers.SecurityUsersDataTable dtUsers =
taUsers.GetByUserName(userName);
8
9 if (dtUsers.Rows.Count != 0)
10 {
11 dtUsers[0].password = hashedPassword;
12
13 try
14 {
15 taUsers.Update(dtUsers);
16
17 success = true;
18 }
19 catch
20 {
21 //
22 }
23 }
24
25 return success;
26 }
The exception occurs on line 15 above. I have looked through the
SecurityUsers.Designer.cs file created by VS, and I can find the methods;
I'm not a C# expert, but nothing jumped out at me as to why this would be
happening.
I thought that VS kindly generated what was needed to map the parameters and
pass them with the method(s) it creates. If I add "= NULL" to all params in
the SPROC, the error goes away, but nothing gets updated. The Update method
is not passing the variables via the datatable, and I don't know where to
look to try to troubleshoot this. Can anyone help?- Hide quoted text -

- Show quoted text -
I am having the same problem withthe update() method. This has occured
once before and I basically had to delete the table adapter from the
record set designer and recreate all the objects on the form that were
limked to it. This did work, but not sure why.

Now I am seeing the same problem come up again and am less will to
duplicate my work again. I did some browsing on the web and found some
information that indicated there was a problem with how vs has
assigned the "@isnull_columnname" parameter a datatype when the table
adapter was created.

Here is my solution: If you select the table adapter in question on
the recordset designer and expand the "update command" under
properties, yu will be able to edit the parameters collection. Scroll
through these and make sure all of your datetime fields have thier
corresponding "@isnull_columnname" parameter set to an int32 datatype.

After looking at the stored procedure (vs generated) behind this
command i am still unsure why this fix works. the Stored Procedure is
expecting a datetime type for these variables. Any who has any more
info about this would be appreciated.

Jul 16 '07 #5
Thank you, thank you, thank you. Your solution does "fix" the problem. I
don't understand how this is working with the SPROC, but at least I can move
on. Thanks again for taking the time to post this.

"fa****@comcast.net" wrote:
On Jul 13, 11:24 am, RParker <RPar...@discussions.microsoft.com>
wrote:
So now my new problem. The error (below in original post) is resolved, but
using the same code, I am now getting the following when calling the Update()
method:

"Failedtoconvertparametervaluefrom aInt32toDateTime"

I'm researching this, but if anyone has any ideas, I'm all ears. I've
looked at this for so long, I have no objectivity. The only variable that isInt32is the userIDparameterand column. The SPROC and method stub for
Update() is all referencing the correct data types.

Thanks,
Rparker

"RParker" wrote:
I used the wizard to generate a typed dataset for my table and let it create
my SPROCs. It created everything, and the GetData() method and the custom
GetByUserName query works great, but when I try to call the Update() method
of my TableAdapter, I get the following:
"Procedure 'stp_SecurityUsers_Update' expectsparameter'@userName', which
was not supplied."
@userName happens to be the first param in the SPROC. Here is the SPROC
that VS2005 generated for me:
<-- start SPROC -->
CREATE PROCEDURE stp_SecurityUsers_Update
(
@userName varchar(15),
@lastName varchar(50),
@firstName varchar(50),
@email varchar(50),
@password varchar(50),
@dateAddeddatetime,
@lastLogindatetime,
@status bit,
@pwdExpired bit,
@lastPasswordChangedatetime,
@Original_userID int,
@Original_userName varchar(15),
@IsNull_lastName varchar(50),
@Original_lastName varchar(50),
@IsNull_firstName varchar(50),
@Original_firstName varchar(50),
@IsNull_email varchar(50),
@Original_email varchar(50),
@IsNull_password varchar(50),
@Original_password varchar(50),
@IsNull_dateAddeddatetime,
@Original_dateAddeddatetime,
@IsNull_lastLogindatetime,
@Original_lastLogindatetime,
@IsNull_status bit,
@Original_status bit,
@IsNull_pwdExpired bit,
@Original_pwdExpired bit,
@IsNull_lastPasswordChangedatetime,
@Original_lastPasswordChangedatetime,
@userID int
)
AS
SET NOCOUNT OFF;
UPDATE [dbo].[tb_SecurityUsers] SET [userName] = @userName, [lastName] =
@lastName, [firstName] = @firstName, = @email, [password] = @password,
[dateAdded] = @dateAdded, [lastLogin] = @lastLogin, [status] = @status,
[pwdExpired] = @pwdExpired, [lastPasswordChange] = @lastPasswordChange WHERE
(([userID] = @Original_userID) AND ([userName] = @Original_userName) AND
((@IsNull_lastName = 1 AND [lastName] IS NULL) OR ([lastName] =
@Original_lastName)) AND ((@IsNull_firstName = 1 AND [firstName] IS NULL) OR
([firstName] = @Original_firstName)) AND ((@IsNull_email = 1 AND IS NULL) OR
( = @Original_email)) AND ((@IsNull_password = 1 AND [password] IS NULL) OR
([password] = @Original_password)) AND ((@IsNull_dateAdded = 1 AND
[dateAdded] IS NULL) OR ([dateAdded] = @Original_dateAdded)) AND
((@IsNull_lastLogin = 1 AND [lastLogin] IS NULL) OR ([lastLogin] =
@Original_lastLogin)) AND ((@IsNull_status = 1 AND [status] IS NULL) OR
([status] = @Original_status)) AND ((@IsNull_pwdExpired = 1 AND [pwdExpired]
IS NULL) OR ([pwdExpired] = @Original_pwdExpired)) AND
((@IsNull_lastPasswordChange = 1 AND [lastPasswordChange] IS NULL) OR
([lastPasswordChange] = @Original_lastPasswordChange)));
<!--end SPROC-->
Here is the code used to try to update a user's record with a new password:
1 public static bool SetPassword(string userName, string hashedPassword)
2 {
3 bool success = false;
4
5 SecurityUsersTableAdapter taUsers = new
SecurityUsersTableAdapter();
6
7 SecurityUsers.SecurityUsersDataTable dtUsers =
taUsers.GetByUserName(userName);
8
9 if (dtUsers.Rows.Count != 0)
10 {
11 dtUsers[0].password = hashedPassword;
12
13 try
14 {
15 taUsers.Update(dtUsers);
16
17 success = true;
18 }
19 catch
20 {
21 //
22 }
23 }
24
25 return success;
26 }
The exception occurs on line 15 above. I have looked through the
SecurityUsers.Designer.cs file created by VS, and I can find the methods;
I'm not a C# expert, but nothing jumped out at me as to why this would be
happening.
I thought that VS kindly generated what was needed to map the parameters and
pass them with the method(s) it creates. If I add "= NULL" to all params in
the SPROC, the error goes away, but nothing gets updated. The Update method
is not passing the variables via the datatable, and I don't know where to
look to try to troubleshoot this. Can anyone help?- Hide quoted text -
- Show quoted text -

I am having the same problem withthe update() method. This has occured
once before and I basically had to delete the table adapter from the
record set designer and recreate all the objects on the form that were
limked to it. This did work, but not sure why.

Now I am seeing the same problem come up again and am less will to
duplicate my work again. I did some browsing on the web and found some
information that indicated there was a problem with how vs has
assigned the "@isnull_columnname" parameter a datatype when the table
adapter was created.

Here is my solution: If you select the table adapter in question on
the recordset designer and expand the "update command" under
properties, yu will be able to edit the parameters collection. Scroll
through these and make sure all of your datetime fields have thier
corresponding "@isnull_columnname" parameter set to an int32 datatype.

After looking at the stored procedure (vs generated) behind this
command i am still unsure why this fix works. the Stored Procedure is
expecting a datetime type for these variables. Any who has any more
info about this would be appreciated.

Jul 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
2
by: Oscar Thornell | last post by:
Hi, I have a general all purpose class that can take the name of a stored procedure and return a dataset... This general dataset that is returned I wish to cast to a strongly typed dataset of...
2
by: a | last post by:
how to send an xml dataset to a Stored Procedure in mssql I have an xml file that I read into a dataset. and I'm trying to use a stored procedure (see SPROC #1 below) that inserts this xml...
1
by: Trond | last post by:
I have a class MessageController that has a method GetMessagesDataset that connects to a database SPROC. When done it returns a dataset. Then in my ASP.NET for i do this: msgController = new...
7
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and...
4
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
7
by: Bob | last post by:
Hi, I have a typed unbound dataset that is passed to a datahandling class to be filled. The datahandling class fills it from a sproc using an oledbDataAdapter (SQLAnywhere database) The only...
2
by: Bob | last post by:
Well, Damned if I know. It used to be simple. Make a webservice that publishes a get method, an update method and a typed dataset. The webpage would get the dataset and show it in a grid, the...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.