.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

Returning last 4 digits of an ssn populated by dirty data

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :Sql Server
I have an ssn column that some times has a valid 9 digit ssn, sometimes has format characters, sometimes has "garbage" (including less that 4 characters as it is a test database), null, etc. I would like to write a substring statement that will return the last 4 digits of the ssn if it is valid. What would be the best way to do that in t-sql?

View Complete Post

More Related Resource Links

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Entity Data Model and database view returning the same columns as there are in a table


When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined. 

How do I do something similar for a view?

I mean assuming I have a view like this

CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...

(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.

var foos = myDB.FilteredFoos.Include("Bar").ToList();

foreach (Foo foo in foos) { ...

Thanks, Jenda

Need help with Dropdown list populated using a data source


I have a dropdownlist that I am trying to populated from a data source using an Oracle db. I can't get any data with the code I have. Can this be down in Sharepoint? Here is the code I am using:


<asp:DropDownList runat="server" id="DropDownList2" AutoPostBack="true"  DataValueField="POPULATION_LIST_ID" DataSourceID="sdsLastName" DataTextField="Last_Name" Visible="True" Height

returning data as hyperlink works but doesn't work


Please help. I have a form that searches my database and returns results well but each record contains a cell with a link to another html page. The problem is that whether I place the html pages in the same directory as the .asp codes or in a separate directory with the link being an absolute URL, the action of clicking on the link fails to redirect. Is it possible?

The returns are addresses and the link in each record is to it's own address page with google map.

TCPClient and Read not returning complete data unless I use thread.sleep


Hello experts, here is my code that I have a question on:

 Dim receivedbyte(1024) As Byte
        Dim myread As Integer = 0
        Dim myresponsesb As New StringBuilder()
            myread = myns.Read(receivedbyte, 0, receivedbyte.Length)
            myresponsesb.Append(System.Text.Encoding.UTF8.GetString(receivedbyte, 0, myread))

        Loop While (myns.DataAvailable)

In the above, myns is a networkstream that is initialized with a tcpclient that is communicating with a XMPP server. basically, iam getting back xml messages.

The issue with the above is that if I dont use thread.sleep(500), the complete data is not returned. Why is that? I have tried to use a streamreader instead of read and using that method i can get complete data from the stream. What am I doing wrong with the Read method of networkstream?

SECOND: The XML being returned from the server is not well formed - the closing tag for one of the tags is missing and I am unable to use XDocument to parse this XML because of this. What could be the issue here? Is it my code or something on server end?

Also, what technique should i use to make the returned XML well formed so that I can use XDOCUMENT and LINQ to parse this?


Windows: Combox Box within a datagrid not populated with data


I am doing when the form  loads up


DataGridViewComboBoxColumn ComboTextCol = new DataGridViewComboBoxColumn();
            ComboTextCol.Headertext = "some";
            ComboTextCol.DataSource =  GetEmployees().Select(e => new { Name = e.LastName + " ," + e.FirstName, ID = e.EmployeeID }).ToList();
            ComboTextCol.ValueMember = "ID";
            ComboTextCol.DisplayMember = "Name";

I tried this too datagrid.Columns.Add(ComboTextCol).

GetEmployees gives employee data

I see the column but  not the the data...??

Select * query not returning all data in a row.


I am using SQL Server 2008 and am new to databases so this may be an obvious one to others.  I have setup a database and have 2 rows in a table which I am trying to read.  If I write a query in SQL Server it works fine, but the exact same query via ODBC connection only returns some of the of data in the affected rows.   The data not being returned is rather large (text field +1000 characters) but even if I create a row with just 1,2,3,4, (one in each column) it still only returns some of the data. 

SELECT * FROM [database].[dbo].[table] WHERE [station_name] = 'XXXXX'

Expected return XXXXX 1 3 5 10-11-2010  (where XXXXX is station name from above)

Actual return XXXXX (null) (null) 5 10-11-2010

The server the database resides on is administrated by IT so I have no idea what settings it has.  I had everything running in a MySQL database and my boss wanted it in MSSQL on the new server so I am trying to convert. This is the last thing that doesn't work.

returning data from xmlQuery


I have a table with 2 columns, first column called ObjectID - GUID field with Primary INdex, then a field called xmlData that is XML data type.

I want to get all ObjectIDs where certain xpath criteria matches the data in the xmlData field

here's what I have so far for the query, but it keeps returning data even if the xPath does not match



ObjectID, xmlData.query('

for $data in //xml/data

where $data/@value < "5"

return $data'

Returning Data from Inheritance


Hey guys,

I've got an entity that inherits from another, but for some reason the entity that is inheriting isn't showing as an available object?

The parent entity is "Customer" and the child entity is called "RetailCustomer", but only 
"Customer" will show in intellisense as being available?

I'm currently using:

Dim DGEntities As New DecoGlazeEntities

    Function customerQuery() As IEnumerable

        Dim Result = From c In DGEntities.Customers Where c.Id = CustomerId Select c

        Return Result

    End Function

And really need to be using something like this...

Dim DGEntities As New DecoGlazeEntities

    Function customerQuery() As IEnumerable

        Dim Result = From c In DGEntities.RetailCustomers Where c.Id = CustomerId Select c

        Return Result

    End Function

... but VS comes back telling me that RetailCustomers isn't a member of my Entities Context.

Any help would be appricated!


Error returning a data table

  1. public DataTable ExcelToDatatable_dt1  
  2.        &

Data List Returning Incomplete Results


Hi All

I have a page where users can search by company name, the data list is pulled from an Excel spreadsheet hosted on the site.  I'm seeing some strange results returned, for example:

In the company field say there are the following entries:

Anns Company
Bernards Business
Company B
Dermots Domain
Property Company

If I search for "Com" I get the following returns (correct):

Anns Company
Company B
Property Company

If I search for "Der" I get my "Sorry there are no matching results" message (Incorrect)

If I search for "Ann" I get the following returns (Correct):

Anns Company

And if I search for "e" I get the following returns (Correct):

Bernards Business
Dermots Domain
Property Company

It seems random as to why it doesn't return some values, I've tried moving rows around to see if that's the problem but it makes no difference.  My range is set correctly in the spreadsheet.

When I debug the VB code behind, when I search for something that works correctly e.g. "Com" in the above example, once enter the value and click search Visual Studio begins steping into

Problems with returning the data table


public DataTable ExcelToDatatable_dt1
                foreach (GridViewRow rowItem in GridView1.Rows)

JQuery getJSON call to MVC Controller not returning data


This is probably something simple. The following JQuery call is executing can calling the controller and the controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also.

However, the success function is not executing in the browser. Any thoughts or other ways I can debug this?

<script type="text/javascript">
@* var myData = [ {first: "Jane", last: "Doe"}, {first: "John", last: "Doe"} ]; *@

Send Activity not receiving data and not returning data


I am invoking a WCF Service using Send Activity from a WF Service. The target WCF Service is getting called but the inputs and outputs are null. Have defined inputs and outputs of the target WCF Service as MessageContracts. For the input,  have set the IsWrapped to false and for the output have set IsWrapped to true.

I dont receive any error either during WF Service execution or during the target WCF Service execution. From the Debug mode I have checked that : All the four activities Receive, Send, Receive Reply, Send Reply are executing without errors. Data received inside Send is null and data received from Recieve Reply is also null.

Please help.


Returning Data based on Logged on User



I've looked through many of similar threads and i'm still unable to get what i require to work. So decided i would request the help of you guys :o).

Firstly im a newbie on ASP and the code might look shocking.

What im trying to do is return data from (Table1) where the logged in userid = the Userid in (table1). I am using the ASPNET membership logins.

Depending on what i change i get diffrent errors.

"Conversion failed when converting from a character string to uniqueidentifier. "

ASPX File Below

<form runat="server">Welcome back
<asp:LoginName ID="LoginName1" runat="server" />
, Please see below.
<br />
<br />

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="Skill" HeaderText="Skill" 
            SortExpression="Skill" />
        <asp:CheckBoxField DataField="Shared" HeaderText="Shared" 
            SortExpression="Shared" />
        <asp:BoundField DataField="TimeFrame" HeaderText="TimeFrame" 
            SortExpression="TimeFrame" />
        <asp:BoundField DataField="MethodText" HeaderText="MethodText" 
            SortExpression="MethodText" />
        <asp:BoundField DataField="guid" HeaderText="guid" SortExpression="guid" 

Creating webservices for returning the Xml Data


Hi All,


 I am developing simple webservice need to display the information in  xm format like









how can i achieve this please any one send me usefull link



Is Dirty Read Isolation the only option to import data from informix using SSIS consistently


Hi there

I've got a package that imports data from informix database. I'm using iBM Informix ODBC Driver 3.50 with ADO.NET data source to import data. Every now and then the package fails with "Could not do physical order read to fetch next row" issue so did some investigation and found that its due to the lock issue. Most of the guys suggested setting up isolation level to "Dirty Read".

Is it the only option to import data consistenly without any error from Informix? Because with "Dirty Read" you get concurrency issue. 

My other question is; can we use the transaction option with isolation level available is SSIS to get around this issue and if yes then how to approach it. And if it's no then is it limited to oledb sources only.


Regards, Vivek

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