none
.NET / Sql Type conversion RRS feed

  • Question

  • I am planning to use a SP ips_backup which I picked up here after someone's suggestion and pointer. It has a couple of input types I am not used to. This is how the input parameters are defined:

    EXAMPLES (optional)  :
    /*   
            EXEC isp_Backup
           @path = 'E:\MSSQL\Backup\',
           @dbType = 'All',
           @bkpType = 'Full',
           @retention = 5,
           @bkpSwType = 'NV',
           @archiveBit = 0,
           @copyOnly = 0
    */

    ALTER PROC [dbo].[isp_Backup]
    (
     @path varchar(100),
     @dbType sysname = 'All',
     @bkpType char(4) = 'Full',
     @retention smallint = 2,
     @bkpSwType char(2) = 'NV',
     @archiveBit bit = 0,
     @copyOnly bit = 0
    )
    AS

    I don't know how to handle sysname and also even the Char. This is how I defined my input tentatively:

                    cmdm.Parameters.Add ( "@path", SqlDbType.VarChar, 100 ).Value = "";
                    cmdm.Parameters.Add ( "@dbType", SqlDbType.VarChar, 3 ).Value = "All";  // Could not find sysname type here
                    cmdm.Parameters.Add ( "@bkpType", SqlDbType.Char, 4 ).Value = "Full";
                    cmdm.Parameters.Add ( "@retention", SqlDbType.SmallInt, 2 ).Value = 2;
                    cmdm.Parameters.Add ( "@bkpSwType", SqlDbType.Char, 2 ).Value = "NC";  // is it the right way to handle Char type?
                    cmdm.Parameters.Add ( "@archiveBit", SqlDbType.Bit, 2 ).Value = 0;
                    cmdm.Parameters.Add ( "@copyOnly", SqlDbType.Bit, 2 ).Value = 0;
                    cmdm.ExecuteNonQuery ( );

    I would appreciate any corrections.

    Thanks.
    AlexB - Win_7 Pro64, SqlSer64 WinSer64
    Tuesday, February 16, 2010 2:49 AM

Answers

All replies