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

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

ASCII string to integer grouping equivalent?

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

Hi I have been trying unsuccssfully to convert a column of data (mycolumn) from a table (mytable)  that has ascii character strings comprised of characters numbered from 0-255. I need to be able to group the numeric values for each ascii string from each record, into what I call an integer group and write that value back to a different column for each respective record in the table. But, I can't figure out how to modify the following Microsoft code to perform this:



-- Create the variables for the current character string position 

-- and for the character string.

DECLARE @position int, @string char(15)

-- Initialize the variables.

SET @position = 1 

SET @string = 'Du monde entier' --here I don't know how to pass a selected column to the @string

WHILE @position <= DATALENGTH(@string) --here I need to know how to loop through each records ascii string and group the values


 SELECT ASCII(SUBSTRING(@string, @position, 1)),

  CHAR(ASCII(SUBSTRING(@string, @position, 1)))

 SET @position = @position + 1


SET NOCOUNT OFF -- then down here somewhere I need to write each converted string to integers back to the myintegerGroup column


The output from above is below, But I need grouped examp: Du monde entier => 681173210911111010010132101110116105101114


View Complete Post

More Related Resource Links

Encoding.ASCII.GetString(bytes) return string with not expected

Example   byte[] bytes = {  0x36,0x92,0x30,0x94}; string rs=  Encoding.ASCII.GetString(bytes) ; //result rs = ?60?   Is Wrong Result; Result Right is     '60". So this function should fix to properly decode two symbols ' and " Code ASCII ' is 0x92,Code ACII for " is  0x94

geting string from integer using enums


we know 

The .NET Framework contains an Enum called DayOfWeek.

so now if i have an integer 7
how can i ge the string "Saturday" using  the enum

SSIS Error in Script task: "Conversion from string "C002" to type 'Integer' is not valid"


Hi All,

I have a script component in my Dataflow that generates Error Description string.

But I am not trying to convert anything in my Script as you can see below.

Here is the Code inside the SCR_component.


Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Public Class ScriptMain
    Inherits UserComponent
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
     'Use the incoming error number as a parameter to GetErrorDescription
    Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode)
   End Sub
End Class


When I run the package , it fails at this script task with the following error:

Description: System.InvalidCastException: Conversion from string "C002" to type 'Integer' is not valid.


The value "C002" is actually a column in the metadata and its type is "DT_STR". I am not trying to convert it in my Script as you can see

Pondering ASCII ordering in a string comparison



The following query on SQL Server:

Select case when '9:9' < '99' then 1 else 0 end
returns 1

Given, according to http://asciitable.com/ ':' comes after '9' I am surprised that the above query does what it does. Then again I'm clearly making a wrong assumption somewhere.

Can anyone explain this?




http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me
Jamie Thomson

Public Function Testing (ByVal FirstString as String, ByVal FirstInteger as Integer), how to pass a


I have the following function, sometimes I want to pass a DBNULL.Value to the function so I update the database with a null value, but it won't let me as the DBNULL.Value is not a string or an integer, how can I get this to work?

Public Function Testing (ByVal FirstString as String, ByVal FirstInteger as Integer), how to pass a DBNULL.Value?

' update database

Return value

End Function

How can i convert Integer to String in SSIS Derived column.


i have gender column with 0,1 values

i`ve to convert it into 0=male and 1=female,i tried this


BUT it is giving error

TITLE: Microsoft Visual Studio

Error at Data Flow Task [Derived Column [46]]: The data types "DT_WSTR" and "DT_I4" are incompatible for binary operator "==". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.

Error at Data Flow Task [Derived Column [46]]: Attempt to set the result type of binary operation "Gender == 0" failed with error code 0xC0047080.

Error at Data Flow Task [Derived Column [46]]: Computing the expression "[Gender] ==0?"Male":[Gender]==1?"Female":"NA"" failed with error code 0xC0047084. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.

Error at Data Flow Task [Derived Column [46]]: The expression "[Gender] ==0?"Male":[Gender]==1?"Female":"NA"" on "input column "Gender" (114)" is not valid.

Error at Data Flow Task [Deri

Conversion from string to type 'Integer' is not valid


Hi Guys,

I have the following IF Statement checking if the function GetNexstAddress (which gets the ClientID from  GetClientFleetInfo(i).CLIENTID) . SECONDARYCITY

is there.



If GetNextAddress(GetClientFleetInfo(i).CLIENTID).SECONDARYCITY(0) = Nothing Then
NextAddress = " No next Destination"
NextAddress = GetNextAddress(GetxxxxFleetInfo(i).TNO).CITY(0)
End If


somehow I get the error.

+exception{"Conversion from string "111 AA BB" to type 'Integer' is not valid."}System.Exception


Do you have any idea how to fix this?

PS: I have searched through the forum but not found an answer yet.


Workflow create item returning integer... Should be a string.




Im passsing information to a new item in a different list using the create item workflow.


It seems to work from apart from one, critical field. The create item should (i hope) pass a valie from a field  'FIELD' in List A to 'FIELD' in ListB.   in list a the field is a lookup from a reference list.

The create new List item workflow ____ it but only returns the type as an integer (an its the oonly option) .

Can you explain where im going wrong?


Setting the Pipename - Converting integer to string to LPCSTR


I am trying to create a pipename - \\.\pipe\CC-("PID in hex")... I get a PID once I create the process and it is stored in po.dwProcessID.


How do I create the LPCSTR such that it has \\.\pipe\CC-12A2 if 12A2 is the PID in hex.





Playing with Linq grouping: GroupByMany?

One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

Grouping Gridview with jquery

The requirement of the project is to show a table of data with the riskdetails(just for assumption) which have the corresponing values for every month and people used to compare the values for last months.

Building a grouping Grid with GridView and ASP.NET AJAX toolkit CollapsiblePanel

I've posted an update to this post to apply on demand loading of Details data using ASP.NET AJAX PageMethods. I'm demonstrating the usage if CollapsiblePanelExtender client events on the new post. Check it out.

I admit, Matt Berseth is really inspiring me! Few days ago I pass through 2 of his great posts:

.Surrounding your Data Table and Dialog Controls with ComponentArt Styled Panels
.Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls
The first one is pure design tips one which I used for making good presentation of my demo here. The 2nd post is actually the idea.

Grouping Gridview with jquery in asp.net

The requirement of the project is to show a table of data with the riskdetails(just for assumption) which have the corresponing values for every month and people used to compare the values for last months.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX
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