.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Invalid length parameter passed to the SUBSTRING function

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :Sql Server

Hi all,

I am having a weird issue after we upgraded our DB server to SQL 2005.

I have a SP used to extract exchange rate, and a job calls this SP daily. This job worked fine on SQL 2000, and works very well in Management studio if I call this SP seperately, but failed in sql job in 2005.

The error statement pointed to:

select left(@row, charindex(',', @row)-1),  REVERSE(left(@reversedrow, charindex(',', @reversedrow)-1))

The error message is:

Invalid length parameter passed to the SUBSTRING function.

Anyone knows what's the difference for LEFT function between sql 2000 and 2005?


View Complete Post

More Related Resource Links

Invalid length for a Base-64 char array for my coding in ASP.net C#. How to solve it ?


Hi Friends ,

I have done encrypted password and decode but i got error  like  this  " Invalid length for a Base-64 char array" .

Pls help . Thanks


psswd = txtPassword.Text;

pwed = base64Decode(psswd);

public string base64Decode(string sData)
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(sData);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            string result = new String(decoded_char); return result;

Invalid web service call, missing value for parameter: \u0027prefixo\u0027 (AutoCompleteExtender)


Good afternoon.

I'm trying to put an AutoCompleteExtender working, but i'm having an error, that i discovered with Fiddler, that is the reason that the autocomplete doesn't work:

> **{"Message":"Invalid web service call,
> missing value for parameter:
> \u0027prefixo\u0027."**,"StackTrace":"
> at
> System.Web.Script.Services.WebServiceMethodData.CallMethod(Object
> target, IDictionary`2 parameters)\r\n
> at
> System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object
> target, IDictionary`2 parameters)\r\n
> at
> System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
> context, WebServiceMethodData
> methodData, IDictionary`2
> rawParams)\r\n at
> System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
> context, WebServiceMethodData
> methodData)","ExceptionType":"System.InvalidOperationException"}

This is the webservice code:

    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.ComponentModel
    Imports GcpBE750
    Imports ErpBS750
    Imports StdBE750
    ' To allow this Web Service to be called fro

Scalar Function Variable length return value

Would like to write a Scalar Function that returns a variable length string of spaces. Length being determined by an input parameter (int) Maybe I am missing the obvious but it seems impossible because you have to declare the size  of the varchar return variable I know there is a performance hit using scalar functions but we are generating a view that emulates an old fixed file format with lots of unused fields. So it will make the resultant view readable. So I am looking to do select goodfield1,fnSpace(5) as Unusedfield1,goodfield2,fnSpace(10)... from MyView thanks Bob

Invalid WorkflowInstanceID parameter in URL

I start a new workflow instance in SharePoint2007, and when click the "In Progress" Link, i receive the error message. I have installed all service packs metioned in http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/acf3524e-3b12-4f80-89f0-f5eb7cfddf13, but still receive the error The instance id is 55C828FC-5876-46C9-B9DF-E64698BBD5D3, but it was changed to 55C828FC-5876-46C9-FDFF -E64698BBD5D3 Any help would be appreciate

How can i pass function as parameter to show in gridview

Hello, I have one common Data Access function which returns output as dataset which is as below   Public Shared Function ExecuteDataSet(ByVal sql As String, ByVal type As CommandType, ByVal ParamArray parameters As SqlParameter()) As DataSetDim RetVal As Object = Nothing   Try Cmd = Cmd.Connection = OpenConnection() Cmd.CommandType = type Cmd.CommandText = sql Cmd.Parameters.AddRange(parameters) Sda = Ds = Sda.Fill(Ds)       New SqlCommand()New SqlDataAdapter(Cmd)New DataSetCatch ex As ExceptionThrow New Exception(ex.Message.ToString())Finally CloseConnection() Sda.Dispose() End Try   Return Ds End Function   this function normally i use to get data from database and returns to dataset   now,I want to created one more function which output type is gridview and its parameter is  dataset which i got output in previous funtion   i want like this public funtion BindDatatoGridView(ExecuteDataSet("SELECT...",commandType.text,Parameter....)) as GridView End Function   how can i solve this, please help me out

How to add parameter dynamically in jquery & passed it to controller.

my code is like -$("#SelectedIds").val(selectedCheckBox); //i get the ids of selected checkbox here var ss = $("#SelectedIds").val(); // i pass all the ids in a variable var xx= "<%= Url.Action("GetAssignToRequestUrl", "PlanRequest", new { selectedItems = "ss" }) %>"; window.open(xx,"ss",'width=1000px, height=700px'); window.focus(); so in this line i am passing "ss".but in my controller i didnot get the value in a parameter variable, instead i am getting ss as parameter, not the selected ids.how can i do that.Plz help.

Report Parameter Values - Can I use getdate() or now() or any other function?

Hi all,      I have a report that utilizes a calendar function but I need to make it a subscription report. Is it possible to use getdate() or now() on the Report Parameter Values? I have a text box that says Enter a Date and that is where I want to have the default value to be run with the subscription. Please let  me know if possible. Thank you.

Can MVC attributes with a string parameter be fed a function returning a string?


Ok so take for instance this attribute:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "La nuova password e la password di conferma non corrispondono.")]

You can see that the third parameter is a string that I would want to localize, hence I would like to delete that message and replace it with a function call, say something along the lines of this:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = GetLocalization("strErrPassMustMatch")]

Do you think it would be possible? If I got *any* chance to do it, then good, I will be setting up a system to do this :-P otherwise, I'll have to find some other way :-)

What can you tell me?

Thank you!


Function with output parameter



is it possible to create user define function with 3 output parameter. something like ref out parameter in C#.

Best Regards. Morteza


Invalid length for a Base-64 char array - how do I check the length?????


Invalid length for a Base-64 char array

I am encrypting and decrypting my querystring. I need a way of checking the querystrings length before I decrypt it. When I mess with the querystring, shorten it for example, my decryption method fails. Can somebody help me with the if statement please to check the length of the urlDecode string??????

public static string Decrypt(string inputText)      {          if (!String.IsNullOrEmpty(inputText))

Retrieve function's output parameter




Is it a way to retrieve the particular function's list of output parameter fields?

the following is the sample code for the list of input parameter fields.

  FROM sys.objects vw
  INNER JOIN sys.parameters p ON p.object_id = vw.object_id
  WHERE vw.type IN (N'FN', N'IF', N'TF') and is_ms_shipped = 0


Meng Chew

Length of the data to decrypt is invalid. tripleDES c#


Hey there.. i am trying to make an Encrypt and Decrypt method...

When i try to encrypt it goes fine.. but when i right after try to decrypt it i get an:

"Length of the data to decrypt is invalid" error...

the error occours when i try to run the code FlushFinalBlock();

here is my code:

        public string Encrypt(string plainText)
            UTF8Encoding utf8Encoder = new UTF8Encoding();
            byte[] inputInBytes = utf8Encoder.GetBytes(plainText);
            TripleDESCryptoServiceProvider tdesProvider = new TripleDESCryptoServiceProvider();
            ICryptoTransform cryptoTransform = tdesProvider.CreateEncryptor(symKey, IVKey);
            MemoryStream encryptedStream = new MemoryStream();
            CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);

            cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
            encryptedStream.Position = 0;
            byte[] result = new byte[encryptedStream.Length];
            encryptedStream.Read(result, 0, (int)encryptedStream.Length);
            return utf8Encoder.GetString(result);

        public string Decrypt(string encryptedString)
            UTF8Encoding utf8Encoder =

System.Management.ManagementException: Invalid parameter


I have created a windows Service which invokes executables on remote machines, waits for it to complete and then proceeds to the next machine on the network.
The Account type for the windows Service is "Network Service". For monitoring if the process is completed on the remote machine, I am using ManagementEventWatcher class. I get the following error when I start the Management event watcher object.

System.Management.ManagementException: Invalid parameter
at System.Management.ManagementException.ThrowWithExt endedInfo(ManagementStatus errorCode)
at System.Management.ManagementEventWatcher.Start()

The code (VB.net 1.1) I am using is as follows:

Dim connection As New System.Management.ConnectionOptions
connection.Username = v_sUserName
connection.Password = v_sPassword
connection.EnablePrivileges = True

Dim oPath As New ManagementPath("\\" & v_sServerName & "\root\CIMV2")
Dim oScope As New System.Management.ManagementScope(oPath, connection)
oScope.Options.Impersonation = ImpersonationLevel.Impersonate

Dim processClass = New System.Management.ManagementClass("Win32_Process")
processClass.Scope = oScope

Dim inParams = processClass.GetMethodParameters("Create")

function parameter description


I have written a function and want to add some description against each paratemeter it takes, how can i do this in vb.net?

Public Function GetTopNArticles(ByVal ArticleTypeID As String, ByVal NoOfArticlesReturned As String, ByVal ExcludingArticleIDs As String) As SqlDataReader

database parameter specified with the configdb command is invalid error


Im using:

Windows server 2008 32 bit. SQL Server 2008 Enterprise. Sharepoint server 2007 Sp2.

I am trying to runthe fllowing command but getting the error that follows:

Psconfig -cmd configdb create -server "sername" database DBName user Domain\user password pswd admincontentdatabase SharePoint_AdminContent

The database parameter specified with the configdb command is invalid.
The database name located at the specified database server has an incorrect coll
ation.  Rebuild the database with the Latin1_General_CI_AS_KS_WS collation or cr
eate a new database using the Latin1_General_CI_AS_KS_WS collation.

Can anyone tell me how to sort this out?


Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


Use a column as parameter for a sds in another column; gridview


Hola, I have a gridview which is bound to a sds which returns 7 columns and I added two columns from the GUI.  What I want is to fill up the 9th column with DDLs and these  DDLS will get their data from a different sds which is using a stored procedure with a single parameter.  I created the 9th row, used template field, made the sds for 9th row, the stored_procedure, threw a DDL in Item template and all  I need now is to pass a parameter in the first column to the sds in the 9th column.  I can code this but i'm getting tired of aspx.cs :) and would like to do it from the GUI.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend