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. Database & SysAdmin
  3. Database
  4. How Do I

How Do I

Scheduled Pinned Locked Moved Database
question
5 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.
  • Y Offline
    Y Offline
    Yaakov Davis
    wrote on last edited by
    #1

    Insert data from a .txt file into a table, using the osql tool? Assume I have table TableA with 3 columns named Column1, Column2 and Column3, and I have a text file 1.txt with the values -seperated by tabs. Thanks, Yaakov

    Y J D 3 Replies Last reply
    0
    • Y Yaakov Davis

      Insert data from a .txt file into a table, using the osql tool? Assume I have table TableA with 3 columns named Column1, Column2 and Column3, and I have a text file 1.txt with the values -seperated by tabs. Thanks, Yaakov

      Y Offline
      Y Offline
      Yulianto
      wrote on last edited by
      #2

      Why do you want to use osql. You can import directly through Import Data with the Data Source your text file.


      Work hard, Work effectively and a bit of luck is the key to success.
      Y 1 Reply Last reply
      0
      • Y Yulianto

        Why do you want to use osql. You can import directly through Import Data with the Data Source your text file.


        Work hard, Work effectively and a bit of luck is the key to success.
        Y Offline
        Y Offline
        Yaakov Davis
        wrote on last edited by
        #3

        I dont have the Import Data tool. I use Sql Express 2005.

        1 Reply Last reply
        0
        • Y Yaakov Davis

          Insert data from a .txt file into a table, using the osql tool? Assume I have table TableA with 3 columns named Column1, Column2 and Column3, and I have a text file 1.txt with the values -seperated by tabs. Thanks, Yaakov

          J Offline
          J Offline
          j1webb
          wrote on last edited by
          #4

          I can't guarantee all of this code because I pulled it out of one of my programs and then edited it down to what I thought you could use, but I did not test it. Private Sub loadDatagrid() boolBeenToGatagrid = True AddRecords() strImportfolder = aPath 'this is the folder in which the file resides strFilename = "selectdata.csv" 'this is the csv file to be imported strConnstr = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + strImportfolder + ";Extensions=asc,csv,tab,txt;Persist Security Info=False;" Conn = New System.Data.Odbc.OdbcConnection(strConnstr) da = New System.data.Odbc.OdbcDataAdapter("select * from [" + strFilename + "]", Conn) Try ds2.Clear() da.Fill(ds2, "TableName") Catch esc As Exception System.Windows.Forms.MessageBox.Show(esc.Message, "") End Try With DataGrid1 .SetDataBinding(ds2, "TableName") ' Set DataGrid Background Color .GridLineColor = System.Drawing.Color.Black .BackgroundColor = System.Drawing.Color.Lavender ' Set DataGrid Caption Background Color .CaptionBackColor = System.Drawing.Color.SlateBlue ' Set DataGrid Caption Foreground Color .CaptionForeColor = System.Drawing.Color.White 'LemonChiffon ' Set DataGrid Parent Rows Background Color .ParentRowsBackColor = System.Drawing.Color.Lavender ' Set DataGrid Parent Rows Foreground Color .ParentRowsForeColor = System.Drawing.Color.SlateBlue ' Set DataGrid Caption Text .CaptionText = "Study List" ' Clear DataGrid Table Styles .TableStyles.Clear() End With ' Set data grid Table Style Dim tblCrrncMngr As System.Windows.Forms.CurrencyManager = CType(BindingContext(ds2.Tables.Item("TableName")), System.Windows.Forms.CurrencyManager) Dim TblStyle As New System.Windows.Forms.DataGridTableStyle With TblStyle .MappingName = "TableName" ''''''.MappingName = "Studies" .BackColor = System.Drawing.Color.White .ForeColor = System.Drawing.Color.Black 'DarkSlateBlue .GridLineColor = System.Drawing.Color.Black 'MediumSlateBlue .HeaderBackColor = System.Drawing.Color.Lavender .HeaderForeColor = System.Drawing.Color.DarkBlue 'MediumSlateBlue .

          1 Reply Last reply
          0
          • Y Yaakov Davis

            Insert data from a .txt file into a table, using the osql tool? Assume I have table TableA with 3 columns named Column1, Column2 and Column3, and I have a text file 1.txt with the values -seperated by tabs. Thanks, Yaakov

            D Offline
            D Offline
            Dr_X
            wrote on last edited by
            #5

            Look into the BCP command line utility. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

            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