Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Using AddOutParameter and the DAAB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pete - 04 Jul 2006 20:56 GMT
Hi,

I'm running into an error while trying to get the output value of an
identity column.  In my database, the identity column is of type 'bigint',
which is what seems to be causing the problem.

The DAAB syntax I'm using for adding in an output parameter is:

string storedProcName = "myInsertProcName";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand(myInsertProcName);

//add Input parameters - works fine

db.AddOutParameter(cmd, "idColumn", DbType.Int64, ???);

As you can see from the line above, the ??? is where I hit my problem.  The
API requires an 'int size' with the description being the max possible size
of the return value.  I tested this issue with a dummy table, setting the
seed to int.maxvalue, and it does throw an exception, with an arithmetic
error.  While I don't have this many records yet, I anticipate it in the
future.  

I should probably mention it is an insert method, and I'm running
db.ExecuteNonQuery(cmd) against the database.  

I looked around and couldn't find anyone else running into this problem, so
any help would be appreciated.  

Thanks,
Pete

Kevin Yu [MSFT] - 05 Jul 2006 04:23 GMT
Hi Pete,

The last argument of AddOutParameter is a value for the size of the
parameter. It is the number of bytes, but not max value you might input.
Since it is an Int64 value, it is 64 bits long, and thus is 8 bytes long.
So use 8 as the size value.

db.AddOutParameter(cmd, "idColumn", DbType.Int64, 8);

HTH.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Pete - 05 Jul 2006 18:29 GMT
Thanks Kevin.  I was able to test it today, and it worked just fine.   I
appreciate the quick response.  

-Pete

> Hi Pete,
>
[quoted text clipped - 19 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Kevin Yu [MSFT] - 06 Jul 2006 04:56 GMT
You're welcome, Pete. It was nice to know that you have had the problem
resolved. Thanks for sharing your experience with all the people here. If
you have any questions, please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.