.net method that writes .csv file to SQL Server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rasta

    #16
    Re: .net method that writes .csv file to SQL Server

    So this is you trying to 'help'- Do all of us a favor and stop.

    "" <a@b.com> wrote in message news:zfNIe.2147 $J7.181@fe07.lg a...[color=blue]
    > oh, and need i keep you from bitching about compile errors by reminding
    > you
    > to import system.text.reg ularexpressions ?
    >
    > you truly need to tone down the attitude toward those trying to help
    > others!
    >
    >
    > "" <a@b.com> wrote in message news:zcNIe.2146 $J7.1334@fe07.l ga...
    > | "shriop" <shriop@hotmail .com> wrote in message
    > | news:1123252165 .635174.259830@ g49g2000cwa.goo glegroups.com.. .
    > | Am I missing something in your proposed solution? I had to assume a
    > | bunch of escapes just to get it to compile.
    > |
    > | you indeed ARE missing something...lik e a clue and/or just a LITTLE
    > knowlege
    > | of c# !!!
    > |
    > | but for you c# (or otherwise) challenged:
    > |
    > | Private Function splitFields(ByV al csv As String) As String()
    > | Dim exp As New Regex(",(?=(?:[^""]*\""[^""]*"")*(?![^""]*""))")
    > | Return exp.split(csv)
    > | End Function
    > |
    > | Private Function splitLine(ByVal csv As String) As String()
    > | Dim exp As New Regex("\r\n")
    > | Return exp.Split(csv)
    > | End Function
    > |
    > | Public Sub Main()
    > | Dim data As String() = splitLine( _
    > |
    > """a"",""b"","" c"",""d"",""e"" ,"""",""f"""
    > | & vbCrLf & _
    > |
    > """g"",""h"","" i"",""j"",""k"" ,"""",""l"""
    > | _
    > | )
    > | If data Is Nothing Then Return
    > | Dim record As String
    > | For Each record In data
    > | Dim fields As String() = splitFields(rec ord)
    > | If Not fields Is Nothing Then
    > | Dim field As String
    > | For Each field In fields
    > | Console.WriteLi ne(field)
    > | Next
    > | End If
    > | Next
    > | End Sub
    > |
    > |
    > |
    >
    >[/color]


    Comment

    • Rasta

      #17
      Re: .net method that writes .csv file to SQL Server

      Thanks, I'll give that a try.


      "Paul Clement" <UseAdddressAtE ndofMessage@sws pectrum.com> wrote in message
      news:iv27f1ddge 86tn4nnthtgh3ik bnvgb2pdr@4ax.c om...[color=blue]
      > On Thu, 4 Aug 2005 13:18:53 -0700, "Rasta" <aboehme@netgat e.net> wrote:
      >
      > ¤ Hi,
      > ¤
      > ¤ I want to create a vb.net procedure that opens a .csv file from a
      > specified
      > ¤ directory and then load that file into a SQL server table located on a
      > ¤ remote server. Can someone point me towards a code sample that does
      > this?
      > ¤ Can I set this up to run at a specified time on windows 2000 server, and
      > how
      > ¤ do I do this. I"m familiar with task schedular in XP but don't know what
      > the
      > ¤ equivalent of this is in 2000 server.
      >
      > You can use SQL w/BULK INSERT:
      >
      > BULK INSERT Northwind.dbo.[Order Details] FROM 'e:\My
      > Documents\TextF iles\OrderDetai ls.txt'
      > WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' )
      >
      > http://msdn.microsoft.com/library/de...ba-bz_4fec.asp
      >
      > AFAIK, Windows 2000 Server does have a Schedule Tasks Control Panel
      > applet.
      >
      >
      > Paul
      > ~~~~
      > Microsoft MVP (Visual Basic)[/color]


      Comment

      • 

        #18
        Re: .net method that writes .csv file to SQL Server


        "Rasta" <aboehme@netgat e.net> wrote in message
        news:%2367mBMem FHA.2152@TK2MSF TNGP14.phx.gbl. ..
        | Ah, the small minded resort to insults when they have nothing intelligent
        to
        | say...

        the insult was not to you, rasta. i'm trying to help you.

        | Below is an example of what I'm looking for just for your enlightenment.
        | Maybe this will help you out next time you try to offer one of your
        pathetic
        | 'solutions'.

        you asked for the c# code to be converted to vb.net...so i did. did you not
        run the code and test it? did it not work? i'd usually stay away from biting
        the hand that feeds you...i'm going to assume your response is a reaction to
        the *perceived* insult you think i threw your way.

        <snip lots of code>

        | ps: you may want to debug your 'code' before posting next time, Einstein.

        true enough...howeve r, i assumed you were familiar enough with c# to
        correctly convert the example to vb.net. it compiles and runs fine in either
        example i gave.

        again, i'll ignore the "einstein" insult as i feel it is a reactionary
        defensive comment. you'll be able to clear up this assumption in your next
        post. if i'm correct, i'll be happy to help you with integrating the example
        with your specific validation routine or even setting up a dts package...if
        i'm NOT correct and you truly intend to be insulting, i'll quietly go away.

        hth,

        me


        Comment

        Working...