Thanks for your reply. It brought me one step closer, but it isn't quit
working yet... The problem is that my comma seperated values are not in a
.csv file but in a .dat file. The ODBC text driver seems to have a problem
with this since it does work if I copy the .dat file to a .csv file. Is this
a bug in the ODBC text driver??
This is my code that works:
Private Sub Button_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button.Click
Dim qry As String
Dim conODBC As New
System.Data.Odbc.OdbcConnection("DBQ=C:\LOG\RADBOUD1.111;Driver={Microsoft
Text Driver (*.txt; *.csv)};Extensions=dat,csv;")
Dim cmdODBC As System.Data.Odbc.OdbcCommand
conODBC.Open()
qry = "select * from callinfo.csv"
cmdODBC = New System.Data.Odbc.OdbcCommand(qry, conODBC)
DataGrid1.DataSource = cmdODBC.ExecuteReader()
DataGrid1.DataBind()
conODBC.Close()
End Sub
If I change the qry parameter to select data from callinfo.dat, which is the
file that I ultimatedly want to use, then I get the error: "ERROR [42000]
[Microsoft][ODBC Text Driver] Cannot update. Database or object is
read-only."
This is weird, because the callinfo.dat file is NOT readonly...
I have also tried to use the Jet OleDB provider, but I basically get the
same result: Works with the .csv file but not with my original .dat file.
Error: "Cannot update. Database or object is read-only."
This is the code:
Private Sub Button_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button.Click
Dim con As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Log\Radboud1.111;Extended
Properties=""text;HDR=NO;FMT=Delimited""")
Dim cmd As System.Data.OleDb.OleDbCommand
Dim qry As String
con.Open()
qry = "select * from callinfo.dat"
cmd = New System.Data.OleDb.OleDbCommand(qry, con)
DataGrid1.DataSource = cmd.ExecuteReader()
DataGrid1.DataBind()
con.Close()
End Sub
I would greatly appreciate any more insight that you or anybody else might
have in this.
Thanks,
Radboud
"Elan Zhou(MS)" <yxzhou...@microsoft.com> wrote in message
news:jp3zJXo...@cppssbbsa01.microsoft.com...
> Hi,
>
> The .Net OLEDB Data Provider does not work with ODBC drivers. In order to
> work with ODBC driver in .Net, the ODBC.Net Data Provider needs to be
used.
> It is an add-on component to the .NET Framework SDK and it can be
> downloaded from
>
http://msdn.microsoft.com/downloads/default.asp?url=/code/sample.asp?url=/ms
> dn-files/027/001/668/msdncompositedoc.xml&frame=true
>
> Another possible option to read from CSV file is to use the Jet Provider's
> Text IIsam. The connection string would be similar to the following:
> Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Sample;Extended
> Properties=\"text;HDR=YES;FMT=Delimited\""
> An article that addresses using this way in traditional ADO can be found
in
> the following location:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q262537
>
> Best Regards,
> Elan
> Microsoft Support
> This posting is provided "AS IS", with no warranties, and confers no
rights.
"Radboud Platvoet" <r...@digivox.nl> wrote in message
news:ekzw6b#eBHA.2292@tkmsftngp07...
> Hi Elan,
SNIP...
> If I change the qry parameter to select data from callinfo.dat, which
is the
> file that I ultimatedly want to use, then I get the error: "ERROR
[42000]
> [Microsoft][ODBC Text Driver] Cannot update. Database or object is
> read-only."
> This is weird, because the callinfo.dat file is NOT readonly...
SNIP...
See MS KB article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q239471
Jet 4.0 Text IISAM Allows Users to Append Lines to System Files
(Q239471)
This is designed to address a security issue and has a solution:
" To resolve the error, either rename the file extension to one of the
enabled extension types or modify the DisabledExtensions registry key
using the methods in this article. "
Regards,
Neale NOON
Thanks for your help. It works! Although I think that the solution that they
have figured out for this porblem is kind of stupid. Who wants to start
changing registries everywhere where they have to run their query? I can
think of a couple of scenarios where this is a major inconvenience and even
some where it would be impossible. More so, in the light of .NET and ASP.NET
with their so called XCopy distribution method (they say you never have to
install a thing again with it, but just have to copy your release build
directory and drop it onto the target system). First thing I run into is
having to make reg changes!!
Anyway, is there a way to tell the driver to accept my .dat file through the
connection string?
Thanks,
Radboud
"noonie" <noo...@microtech.com.au> wrote in message
news:OJFewUDfBHA.2136@tkmsftngp04...
"Radboud Platvoet" <r...@digivox.nl> wrote in message
news:uLN8KzJfBHA.2292@tkmsftngp07...
> Hi,
SNIP...
Glad it worked for you :-)
> Anyway, is there a way to tell the driver to accept my .dat file
through the
> connection string?
Not that I know of, sorry.
I think the whole registry thing is there to cover what could have been
an embarrassing security problem. I haven't taken the time to imagine a
case where this could be used maliciously but I'm sure it exists ;-)
I had intended to use this method to expose a remote server's web logs
to analysis by SQL queries (.log is one of those forbidden extensions)
but have decided against it. I will copy the logs and rename them
locally.
Regards,
Neale NOON
Thanks again for your help!
"noonie" <noo...@microtech.com.au> wrote in message
news:uOKyCwKfBHA.1880@tkmsftngp07...
"Radboud Platvoet" <r...@digivox.nl> wrote in message
news:OChvRZLfBHA.2292@tkmsftngp07...