Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Database connection in web app
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01506103
Message ID:
01506232
Views:
40
>OK, since I want it for each table then I will add this call in the constructor of ABusinessObject. What is the best way to call this stored procedure? It has one parameter with a sysname type. I tried the following but it does not work:

>
>public ABusinessObject()
>        {
>            // Enter the default database key as specified in the app.config file
>            this.DatabaseKey = "Iluna";
>            this.RetrieveAutoIncrementPK = true;
>            // Specify the default command type for data retrieval
>            this.DefaultCommandType = CommandType.StoredProcedure;
>            this.SetUserNameForAudit("BobF");
>        }
>
>public void SetUserNameForAudit(string userName)
>        {
>            IDbDataParameter param1 = this.CreateParameter("@userName", 0);
>            param1.Direction = ParameterDirection.Input;
>            param1.Value = userName;
>            IDbCommand retValue = this.ExecSproc("pr_kr_AuditSetUserName", param1);
>        }
>
Try using ExecSprocScalar instead. Check out the MM .NET Dev Guide topic "Calling Stored Procedures that Return a Scalar Value" for details.

Also, regarding setting the user name in the ABusinessObject constructor, that really only works if you are hard-coding the user name. If you want a different user name based on the current user, you need to pass the current user to the constructor of each business object.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform