Input to SQL Stored Procedure

I am trying to grab a querystring from the URL and send it to my stored procedure in MSSQL. The querystring is of type varbinary and when i try to send it my application is throwing an exception. I also wanted to return the select statement at the bottom of my storedprocedure that simply says Select 'Processed'

Answers


If you wish Byte[] type, You can try with this code, you don't pass string

cmd.Parameters.Add("@dec", SqlDbType.VarBinary).Value = ;//Relpace with your new Byte[]

Or if you want string type, you can try with string type

cmd.Parameters.Add("@dec", SqlDbType.VarChar).Value = QS;//Your string

Link : http://msdn.microsoft.com/fr-fr/library/system.data.sqldbtype%28v=vs.80%29.aspx


had to actually create a function to parse hex code and then send it to the database

static byte[] ParseHexString(string value)
        {
            if (string.IsNullOrEmpty(value)) return null;
            if (1 == (1 & value.Length)) throw new ArgumentException("Invalid length for a hex string.", "value");

            int startIndex = 0;
            int length = value.Length;
            char[] input = value.ToCharArray();
            if ('0' == input[0] && 'x' == input[1])
            {
                if (2 == length) return null;
                startIndex = 2;
                length -= 2;
            }

            Func<char, byte> charToWord = c =>
            {
                if ('0' <= c && c <= '9') return (byte)(c - '0');
                if ('A' <= c && c <= 'F') return (byte)(10 + c - 'A');
                if ('a' <= c && c <= 'f') return (byte)(10 + c - 'a');
                throw new ArgumentException("Invalid character for a hex string.", "value");
            };

            byte[] result = new byte[length >> 1];
            for (int index = 0, i = startIndex; index < result.Length; index++, i += 2)
            {
                byte w1 = charToWord(input[i]);
                byte w2 = charToWord(input[i + 1]);
                result[index] = (byte)((w1 << 4) + w2);
            }

            return result;
        }

Need Your Help

iPad - dont hide the keyboard for text field

ios ipad keyboard hide

In my iPad application, first view is authentication view.

Why Some Assembly Instruction Are not Documented

delphi assembly inline-assembly 8086

There are some Assembly instruction in Delphi Source Codes which I cannot found anywhere in Assembly Cheat Sheets including:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.