F
Frank
I need to write a program that accesses data in
commaseparated text file. Instead of just reading the
lines and chopping out the text in field values, I
thought that I could use ODBC to just access it as a
table.
I have created a File-DSN for the directory where the
file is located. A specific file cannot be referenced in
the DSN entry. I guess that the individual files are
considered tables for such an entry.
I have then selected an ODBC connection (ODBC connection
1)from the dataobjects tab and have set its
ConnectionString property to the DSN entry:
"SafeTransactions=0;MaxScanRows=8;DefaultDir=F:\Visual
Studio Projects\Nøgleta" & _
"l - Dataopdatering\Test Data;FILEDSN=F:\Visual
Studio Projects\Nøgletal -" & _
" Dataopdatering\Statoil Data\Test
Data.dsn;DriverId=27;UID=admin;UserCommitSy" & _
"nc=Yes;FIL=text;PageTimeout=5;Driver={Microsoft
Text Driver (*.txt; *.csv)};MaxB" & _
"ufferSize=2048;Threads=3"
(this was generated by the VB when i chose new connection
and pointed to the File-DSN)
However, I don't seem to be able to get the Dataadapter
working:
Dim dadapKunde1 As Odbc.OdbcDataAdapter
Dim str_sql As String = "SELECT * FROM Kunddat1.txt"
dadapKunde1 = New Odbc.OdbcDataAdapter(str_sql,
OdbcConnection1)
dadapKunde1.Fill(datsetKunde1, "Kunddat1.txt")
When I run the code there is an error in the last
statement:
"An unhandled exception of
type 'System.ArgumentNullException' occurred in
system.data.dll
Additional information: A Value may not be null"
Perhaps i am handling the reference to the file
(Kunddat1.txt) wrongly. I just don't see where to
reference it otherwise. The DSN entry only points to the
directory. But it should be possible.
Any help is appreciated.
With kind regards,
Frank
commaseparated text file. Instead of just reading the
lines and chopping out the text in field values, I
thought that I could use ODBC to just access it as a
table.
I have created a File-DSN for the directory where the
file is located. A specific file cannot be referenced in
the DSN entry. I guess that the individual files are
considered tables for such an entry.
I have then selected an ODBC connection (ODBC connection
1)from the dataobjects tab and have set its
ConnectionString property to the DSN entry:
"SafeTransactions=0;MaxScanRows=8;DefaultDir=F:\Visual
Studio Projects\Nøgleta" & _
"l - Dataopdatering\Test Data;FILEDSN=F:\Visual
Studio Projects\Nøgletal -" & _
" Dataopdatering\Statoil Data\Test
Data.dsn;DriverId=27;UID=admin;UserCommitSy" & _
"nc=Yes;FIL=text;PageTimeout=5;Driver={Microsoft
Text Driver (*.txt; *.csv)};MaxB" & _
"ufferSize=2048;Threads=3"
(this was generated by the VB when i chose new connection
and pointed to the File-DSN)
However, I don't seem to be able to get the Dataadapter
working:
Dim dadapKunde1 As Odbc.OdbcDataAdapter
Dim str_sql As String = "SELECT * FROM Kunddat1.txt"
dadapKunde1 = New Odbc.OdbcDataAdapter(str_sql,
OdbcConnection1)
dadapKunde1.Fill(datsetKunde1, "Kunddat1.txt")
When I run the code there is an error in the last
statement:
"An unhandled exception of
type 'System.ArgumentNullException' occurred in
system.data.dll
Additional information: A Value may not be null"
Perhaps i am handling the reference to the file
(Kunddat1.txt) wrongly. I just don't see where to
reference it otherwise. The DSN entry only points to the
directory. But it should be possible.
Any help is appreciated.
With kind regards,
Frank