.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

Need to find all lines that have less than 9 commas and add two commas to the end of those lines

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :.NET Framework
I have a .csv file which is missing commas at the end of some of the lines... each line should have 9 commas and I want to add commas to those that have less than 9.

View Complete Post

More Related Resource Links

Richtextbox - how can I find out what lines are currently visible?

I have a scrolling richtextbox that holds more lines than it can display, and I would like to know what lines are currently being displayed.  I'm looking for some method like GetTopVisibleLine, GetBottomVisibleLine, GetFirstVisibleCharIndex, GetLastVisibleCharIndex, etc. and I don't seem to be able to find anything that will give me this info.  Any ideas? Thanks, Mike

Draw lines excactly on physical device pixels

When you draw a line in WPF you will experience that they often appear blurry. The reason for this is the antialiasing system that spreads the line over multiple pixels if it doesn't align with physical device pixels.

Use DB query result to generate Jquery required lines of code



I 'm gonna query database for photo records. each record include "photo path" where imagesURL  stored in string format

 I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.

How could I  generate these lines

$(function() {
sleep: 2,
fade: 1
}, [
{ src: 'picture1.jpg' },
{ src: 'picture2.jpg' },
{ src: 'picture4.jpg' }

Help: Too many lines of code to achieve a simple goal: keep my NULL SQL values...


Hello all

What is the best way (best practice) to preserve my NULL SQL values in the database
during an insert/update operation (without receiving cast invalid errors)?
Also, how to display a string 'n/a' when a sql value is NULL?

My project is using FormView with Edit/Insert templates and classes to represent my tables

Goal1....: display 'n/a' when there are NULL SQL values in the database
Solution1: I am using ISNULL(field,'') in my store procedure for SELECT statements

Goal2....: if the fields are 'n/a', then save them back in the database as NULL
Solution2: on my insert/edit methods I am having to check the values being passed, i.e:

cmd.Parameters.Add(new SqlParameter("@scope", SqlDbType.NVarChar, 50));

if (item.Scope == "n/a")
 cmd.Parameters["@scope"].Value = DBNull.Value;
 cmd.Parameters["@scope"].Value = item.Scope;

Not to mention that for SQL DateType fields when you use ISNULL(field,'') the return string is '1/1/1900 12:00:00 AM'
and I have to change the field value in every field that represents a date, i.e:

protected void FormView1_DataBound(object sender, Sy

Remove the lines from the query output

On TSQL Command of; set nocount onselect @@version Getting the output as;                                                                                                                                                                                                                                                                  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Microsoft SQL Server  2000 - 8.00.2039 (Intel X86)  May  3 2005 23:18:38  Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2) How to remove the lines from the output?

WPF - Drawing the connected lines shape

I want something to draw like in WPF   ___________________________                                        |                                        |                                        | __________________________ | | | ___________________________                                         |                                         |                                         | ___________________________          

Add lines to gridview

Hi, I'm trying add vertical lines to my grid. I have found some examples but nothing works.   <ListView  ItemsSource="{Binding Path=CheckableObjectFacilities}" x:Name="ListViewObjectFacilities" Margin="5">    <ListView.View>        <GridView>            <GridViewColumn>                <GridViewColumn.CellTemplate>                     <DataTemplate>                         <CheckBox IsChecked="{Binding Path=IsChecked}" Click="cboxObjectFacilities_Click" HorizontalContentAlignment="Stretch"/>                     </DataTemplate>                </GridViewColumn.CellTemplate>            </GridViewColumn>            <GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Nazwa" >            </GridViewColumn>            <GridViewColumn DisplayMemberBinding="{Binding Category}" H

Splitting a memo field into lines and adding a value at the start of each line

I have one memo field which has a bunch of text in it. I want to update another memo field from the first one but i want to divide it into lines of 50 characters and put a carriage return at the end of each line and a string value (Note:) at the beginning of each line But I am not sure how to go about it. The text in the first field may have line breaks and carriage returns or it may not. So is there a way i can strip out anything like that first See example below Memo Field1 The quick brown fox jumped over the lazy dog. And the Dish ran away with the spoon, the little dog laughed to see such fun and the Cow fell of the wall Memo Field2 Note: The quick brown fox jumped over the lazy dog. And Note: the Dish ran away with the spoon, the little dog l Note: aughed to see such fun and the Cow fell of the wal Note: l   ideally it wouldn't cut words in half but I think I may be asking too much.   Is this possible?

Miss lines when converting data from TXT to sql

I have several txts files in a folder and I am trying to convert those into my sql database.  There is no error message during the conversion however, it misses converting some lines in my txt. It was showing that the total line number of the txt file was 8644 however after inserting into database, only 8631 shows up. I am so confused how can this happen? For example,   [Flat File Source [1]] Information: The total number of data rows processed for file "E:\My_Txts\20093347.txt" is 8742.  [Flat File Source [1]] Information: The processing of file "E:\My_Txts\20093347.txt" has ended.  and then it shows [DTS.Pipeline] Information: "component "OLE DB Destination" (9)" wrote 8730 rows. 

Wrap text in Multiple Lines of text column

I had a List created from Calendar. I then took two copies of it to use for two slightly different purposes. I created a View on the list in both cases using the "Newsletter" style. On one of the list the Description column wraps text. In the other one it does not. Any idea what I could have done differently? Is there a checkbox in the View definition or the Column definition that toggles wrap text ?

Modal Popup inserting unnecessary Commas


I have a textbox inside modal popup. when i write some data into the textbox and hit ok it is appending unnecessary commas. How to remove them. 

Hide Commas in Number Field when Editing via DataView


I have a list that contains a number field that I am using to capture a numeric value, however I do not want the values displayed with commas (I am using the number column type to keep the user from entering text)  I am displaying the number field in a dataview on which I have enabled the Insert/Edit options.  When the user is inserting a new record the field does not display commas.  When the dataview is in display mode I am able to change the formatting of the value to remove the commas.  Unfortunately, I can not figure out how to remove the commas from the text box when the user is editing an existing entry.

MOSS 2007, SPD 2007


I created a new control and im drawing some lines and points inside but the form1 designer throw me


This is the code of the control:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace My_Diet_Control
    public partial class My_Diet_Graph_Control : UserControl
        int x_axis_lenght;
        int y_axis_lenght;
        int marginLeft;
        int marginRight;
        int marginBottom;
        int marginTop;
        My_Diet_Graph_Control myControl1;
        Diet_Data myData;
        public My_Diet_Graph_Control()

        private void My_Diet_Graph_Control_Load(object sender, EventArgs e)

SQL Server 2008 multiple lines in a varchar(MAX) column?



I'm using varchar(Max) to store a text file content. It's not taking the newline character. I tried \n and char(13) etc.. whatever solution posted in the net.

ex : update test set f='This is line 1.' + CHAR(13) + CHAR(10) + 'This is line 2.' 

after updating it doesn't have any newline or linebreak. Can anyone help me in this how to have linebreaks in the varchar(max) field.

Thanks a lot.

sql agent job command step multiple lines?


This is an oldie but a goodie, maybe there's a trick I haven't heard about?

When I create an OperatingSystem (CmdExec) job step, it seems to only execute the first line command. 

So if the first line is:

dtexec foo

It executes dtexec.  Fine.

But if I have two command lines:

set myvar=123
dtexec foo

It only executes the set command and never calls dtexec.  Bummer.

Now, we can work around this by executing a .cmd file, but then I have a whole issue of deploying .cmd files in different environments yada yada.

So the question is, is there any (new-ish) magic trick that will tell the SQL Agent job step to execute two or more command lines right from the job?




change the color of lines


Please advice---------

Let me explain this.
// aspx
<asp:TextBox runat="server" ID="txtOld" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:TextBox runat="server" ID="txtNew" TextMode="MultiLine" Columns="70" Rows="30" Width="425px" />
<asp:Button Text="Compare" runat="server" ID="btnCompare" OnClick="btnCompare_Click" />

// c#
I have two string

string strOld = "This a line 1\nThis is going to be line 2\rThis is going to be line 3\rThis is line 4";
string strNew = "This a line 1\nThis text is changed here going to be line 2\rThis is going to be line 3\rThis is changed line 4";

Please note that these strings have \n and \r in it.

When form loads, I do something like this
 if (!IsPostBack)
            txtOld.Text = strOld;
            txtNew.Text = strNew;
Web browser automatically splits the strings and align nicely in the Text box like this


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