Showing posts with label assistance. Show all posts
Showing posts with label assistance. Show all posts

Wednesday, March 21, 2012

Retrieving Output paramater after insert

Can some one offer me some assistance?

I'm using a SQLDataSource control to call a stored proc to insert a record into a control. The stored proc I'm calling has an output paramater that returns the new rows identity field to be used later. I'm having trouble getting to this return value via the SQLDataSource . Below is my code (C#):

SqlDataSource1.InsertParameters["USR_AUTH_NAME"].DefaultValue = storeNumber;

SqlDataSource1.InsertParameters["usr_auth_pwd"].DefaultValue =string.Empty;

SqlDataSource1.InsertParameters["mod_usr_name"].DefaultValue ="SYSTEM";

SqlDataSource1.InsertParameters["usr_auth_id"].Direction =ParameterDirection.ReturnValue;

SqlDataSource1.Insert();

int id =int.Parse(SqlDataSource1.InsertParameters["usr_auth_id"].DefaultValue);

below is the error I'm getting:

System.Data.SqlClient.SqlException: Procedure 'csi_USR_AUTH' expects parameter '@.usr_auth_id', which was not supplied.

Has anyone done this before and if so how did you do it?

How did you define the stored procedure 'csi_USR_AUTH' ? Since you add the Direction of usr_auth_id toParameterDirection.ReturnValue, you don't need to declare a @.usr_auth_id parameter in the sp; instead, it will be filled by using a RETURN command. Check this article to see how to use ReturnValue parameter:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconinputoutputparametersreturnvalues.asp

Tuesday, February 21, 2012

Retrieve Deleted Items > Log

Looking for a little assistance with a big problem.

I lost some data from a query that went wrong. I still have the logfile though, is there anyway of retrieving the data from the log file (.LDF) so that I can undo what someone did?

I located some 3rd party software but they are big bucks and the demos won't allow you to do it..

Thanks in advance,

JayThe safest thing would be to backup the transaction log, then restore the database froma full backup with norecovery, then restore the transaction log with 'stopat = time' where time is just before the bad query was run. This assumes that you are in full recovery mode, however.

Alternatively, if you have the disk space, you can restore the database to a new location, and try to transfer some of the lost data over. This is much more risky, as you have to be sure you get all of the relationships, id values, etc. right. Most vendors will invalidate their support contracts, if you do this sort of thing to their databases.