INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SqlDbType.Bit -> MpmType.???

SqlDbType.Bit -> MpmType.???

(OP)
Hi,

I'm new to Mimer and have stumbled across a problem...

I have a stored procedure (in an MS SQL Server Dbase), which has an output parameter of type 'Bit' (the purpose of this param is to indicate whether the stored procedure has run successfully). The problem is that there is no such type in Mimer. Now, logic would dictate that I use the Mimer Type 'Boolean', or even concievably VarBinary with length 1, but alas I seem to get the same runtime error no matter which type I use:

'ArgumentOutOfRangeException: Index was out of range.  Must be non-negative and less than the size of the collection.'

As far as I can tell, this exception is being raised when I declare the direction of my output parameter.

Any thoughts on this would be most appreciated, I am most probably missing something exceedingly obvious, but it is 1.30am and I really do need to get some sleep...

theGrimRipper

RE: SqlDbType.Bit -> MpmType.???

Hi,

Can you please send the code so we can see what you are doing?

By the way, do not confuse Mimer SQL and Mimer Provider Manager. Mimer SQL is relational database just like SQL Server.

Regards,
Fredrik

RE: SqlDbType.Bit -> MpmType.???

(OP)
Here is an example of what I'm trying to do:
(btw, I'm using the Mimer Provider Manger, sorry for any confusion)

Example Stored Procedure in MS SQL Server:
---------------------
CREATE PROC sp_example
     @returnParam Bit OUTPUT
AS
     SET @returnParam = 1
---------------------


Example C# (ADO.Net) Code, attempting to use the above stored proc:
---------------------
MpmConnection dbConn = new MpmConnection("Data Source Name=TEST");
MpmCommand cmd = new MpmCommand("sp_example",dbConn);
cmd.Parameters.Add("@returnParam", MpmType.Boolean);
cmd.Parameters["@returnParam"].Direction = ParameterDirection.Output;

dbConn.Open();
cmd.ExecuteNonQuery();
dbConn.Close();
----------------------

The runtime exception (listed in my original post) seems to be being raised at the point where I specify the direction of the parameter '@returnParam'.

I'm 99% convinced that its to do with my use of 'MpmType.Boolean' as the type of what is actually a Bit in SQL Server.

Any thoughts are appreciated!

theGrimRipper

RE: SqlDbType.Bit -> MpmType.???

(OP)
Problem solved!

A simple mistake... I was attempting to use a parameter's name (as a string), rather than it's index position (integer) to retrieve MpmParameters from an MpmParameterCollection.

theGrimRipper

RE: SqlDbType.Bit -> MpmType.???

(OP)
I was attempting to retrieve a parameter from the MpmParaeterCollection object by using the whole parameter name, see example below:

cmd.Parameters["@returnParam"]

I could instead have used an integer, which represents the parameter's position within the collection, as follows:

cmd.Parameters[0]

Although this approach works, according to the documentation, one should be able to use the parameter's name (as a string) to get it, I found that I could use:

cmd.Parameters["returnParam"]

Basically, just omitting the '@' pre-fix. For some reason this works, whereas leaving the '@' on does not.

Is there any logical reason why this is the case? Do other DBMSs (other than SQL Server) use a different symbol to denote a parameter? If so should I be omitting the '@' symbol when I add new parameters into an MpmParameterCollection object?

Any thoughts would be much appreciated!

RE: SqlDbType.Bit -> MpmType.???

Parameter names in Mimer Provider Manager are without leading @ (as you discovered). To ease migration for existing ADO.NET programs leading : and @ are stripped away (for example when calling the MpmParameter constructor).

However, this could easily be handled the same way when accessing the MpmParameterCollection as well. I suggest you write a Feature Request on http://sourceforge.net/projects/mimerpm and ask for this!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close