Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. check this

check this

Scheduled Pinned Locked Moved .NET (Core and Framework)
sysadmin
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Wendelius

    No, you cannot refer to the contents of the text file as the data source. Use config file or read the text from the textfile, for example using File.ReadAllLines[^] amd then place the contents to your connection string. Something like:

    string[] datasource = File.ReadAllLines("D:\\king.txt");
    string connection = "Provider=SQLOLEDB; Data Source="
    + datasource[0]
    + ";Catalog=STU_ATTENDANCE;User ID=sa;Password=sa; Network Library=dbmssocn";

    The need to optimize rises from a bad design.My articles[^]

    modified on Thursday, January 22, 2009 12:15 PM

    K Offline
    K Offline
    kulandaivel_mca2007
    wrote on last edited by
    #5

    nice gentle man u got my problem... when i include those lines i get this error.... "File does Not exist in the current context"

    W 1 Reply Last reply
    0
    • K kulandaivel_mca2007

      nice gentle man u got my problem... when i include those lines i get this error.... "File does Not exist in the current context"

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #6

      File class is under System.IO namespace, so you can refer to it like System.IO.File.ReadAllLines(... or add using System.IO directive to your file.

      The need to optimize rises from a bad design.My articles[^]

      K 1 Reply Last reply
      0
      • W Wendelius

        File class is under System.IO namespace, so you can refer to it like System.IO.File.ReadAllLines(... or add using System.IO directive to your file.

        The need to optimize rises from a bad design.My articles[^]

        K Offline
        K Offline
        kulandaivel_mca2007
        wrote on last edited by
        #7

        i got this error Could not find file 'D:\king.txt'. but i have word file in my d:

        W 1 Reply Last reply
        0
        • K kulandaivel_mca2007

          i got this error Could not find file 'D:\king.txt'. but i have word file in my d:

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #8

          As the message says, the file cannot be opened. Re-chek the path and the name and if another application is having that file open, close the other application first.

          The need to optimize rises from a bad design.My articles[^]

          K 1 Reply Last reply
          0
          • W Wendelius

            As the message says, the file cannot be opened. Re-chek the path and the name and if another application is having that file open, close the other application first.

            The need to optimize rises from a bad design.My articles[^]

            K Offline
            K Offline
            kulandaivel_mca2007
            wrote on last edited by
            #9

            the file did not open any where in my project... i gave like this... string[] datasource = File.ReadAllLines("D:\\king.txt"); Could not find file 'D:\king.txt'. if i give like this.... string[] datasource = File.ReadAllLines("D:\king.txt"); Error 1 Unrecognized escape sequence //occurs i gave like this... string[] datasource = File.ReadAllLines("D:king.txt"); Could not find file 'D:\king.txt'.

            W 1 Reply Last reply
            0
            • K kulandaivel_mca2007

              the file did not open any where in my project... i gave like this... string[] datasource = File.ReadAllLines("D:\\king.txt"); Could not find file 'D:\king.txt'. if i give like this.... string[] datasource = File.ReadAllLines("D:\king.txt"); Error 1 Unrecognized escape sequence //occurs i gave like this... string[] datasource = File.ReadAllLines("D:king.txt"); Could not find file 'D:\king.txt'.

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #10

              The problem isn't in your code, but the code cannot open the file from the operating system. Check (for example using windows explorer) that: - the file is on drive D and in the root directory - the file is named king.txt - you have privileges to open the file - the file isn't open in any program, for example in Microsoft Word etc.

              The need to optimize rises from a bad design.My articles[^]

              K 1 Reply Last reply
              0
              • W Wendelius

                The problem isn't in your code, but the code cannot open the file from the operating system. Check (for example using windows explorer) that: - the file is on drive D and in the root directory - the file is named king.txt - you have privileges to open the file - the file isn't open in any program, for example in Microsoft Word etc.

                The need to optimize rises from a bad design.My articles[^]

                K Offline
                K Offline
                kulandaivel_mca2007
                wrote on last edited by
                #11

                file read successfully but.. reading in this manner ::ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>\0\0\t\0\0\0ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0

                W 1 Reply Last reply
                0
                • K kulandaivel_mca2007

                  file read successfully but.. reading in this manner ::ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>\0\0\t\0\0\0ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #12

                  Are you sure it's a plain text file and not for example in Word format? Open it using notepad. It should answer that question. File-class reads the text as plain text. If the file contains some other format, File class is unable to "translate" it to text.

                  The need to optimize rises from a bad design.My articles[^]

                  K 1 Reply Last reply
                  0
                  • W Wendelius

                    Are you sure it's a plain text file and not for example in Word format? Open it using notepad. It should answer that question. File-class reads the text as plain text. If the file contains some other format, File class is unable to "translate" it to text.

                    The need to optimize rises from a bad design.My articles[^]

                    K Offline
                    K Offline
                    kulandaivel_mca2007
                    wrote on last edited by
                    #13

                    i typed "veeserv3" in that word doc... it is not empty... "Format of the initialization string does not conform to specification starting at index 0." this error also occured..

                    K 1 Reply Last reply
                    0
                    • K kulandaivel_mca2007

                      i typed "veeserv3" in that word doc... it is not empty... "Format of the initialization string does not conform to specification starting at index 0." this error also occured..

                      K Offline
                      K Offline
                      kulandaivel_mca2007
                      wrote on last edited by
                      #14

                      VERY VERY THANKS GENTLE MAN... I GOT THE RESULT...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups