How Do I
-
Insert data from a .txt file into a table, using the
osql
tool? Assume I have table TableA with 3 columns namedColumn1, Column2
andColumn3
, and I have a text file1.txt
with the values -seperated by tabs. Thanks, Yaakov -
Insert data from a .txt file into a table, using the
osql
tool? Assume I have table TableA with 3 columns namedColumn1, Column2
andColumn3
, and I have a text file1.txt
with the values -seperated by tabs. Thanks, Yaakov -
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.
I dont have the
Import Data
tool. I useSql Express 2005
. -
Insert data from a .txt file into a table, using the
osql
tool? Assume I have table TableA with 3 columns namedColumn1, Column2
andColumn3
, and I have a text file1.txt
with the values -seperated by tabs. Thanks, YaakovI 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 .
-
Insert data from a .txt file into a table, using the
osql
tool? Assume I have table TableA with 3 columns namedColumn1, Column2
andColumn3
, and I have a text file1.txt
with the values -seperated by tabs. Thanks, YaakovLook 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)