ini files

R

Ruslan Shlain

I am getting data from a text file using the folowing code. It uses the
schema.ini file to define a structure of the datatable in the Dataset. The
default file called schema.ini. I have about 10 or 15 tables i have to
populate. Is there a way to specify an ini file i want to use?

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")

Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from " &
FileName, Conn)

Dim DS As New DataSet

Try

Comm.AcceptChangesDuringFill = False

Comm.Fill(DS)

End try
 
W

William Ryan

Ruslan:

If I understand the problem correctly, a .config file may be the way to go.
They are easy to create http://www.knowdotnet.com/articles/configfiles.html
and you can store as much info as you want in there. You won't have to worry
about deploying multiple files and you can branch off conditionally to
different sections.

I think this would provide an elegant solution to your problem.

HTH,

Bill
 
R

Ruslan Shlain

I have to have INI file. That defines structure of the datatable. ADO.NET, I
think, uses it by default. And each table requires different INI file with
defined structure.
Thank you for the help
 
R

Ruslan Shlain

I am getting data from a text file. INI file defines the structure of the
datatable. I provided code example that demonstrates whats going on.
 
W

William Ryan

I must be missign something here.... Are you talking about a standard .ini
file? You can create a DataTable exclusively from code and define it on the
fly...without any .ini file
 
W

William Ryan

Ruslan:

I'm looking at your code and I see you are reading the text file (FilePath
in the connection string). You aren't pulling headers from it, so that's
where the ini file comes in. But where is the call to the .ini file that's
creating the schema for you? But the part that I'm not understanding is 1)
Why will an .ini file work for the definition but a config file won't 2)
Even if you must use an ini for the schema information, if you need to
dynamically choose 15 tables one at a time, since you are dynamically
creating the connection string with variables, why couldn't you use a config
file to load the respective path names and iteratively change the values for
each key? Or, if you don't know where those files will be in advance and
require user intervention, couldn't you just use a OpenFile Dialog box and
retrieve the file information from there?

Additionally, would it be possible to write the columnames as the first row
of each respective datafile and just set the HDR = YES and get the info from
there?

I guess what's confusing me is that you say ADO.NET needs an ini file to
create a DataTable, but you can create a datatable by simply instantiating
it and adding datacolumns to it. Similarly, that info can be inferred from
the first line. There are multiple ways to get there, and it seems like the
only problem is pointing to each file...which could be stored in a .config
file, another .ini or whatever else and just walk a loop substituting the
variables at each pass.

Maybe if I understood the ultimate goal and saw the code where you are
reading the .ini in I could be of more help.

Bill
 
R

Ruslan Shlain

INI file is been grabed by default.


William Ryan said:
Ruslan:

I'm looking at your code and I see you are reading the text file (FilePath
in the connection string). You aren't pulling headers from it, so that's
where the ini file comes in. But where is the call to the .ini file that's
creating the schema for you? But the part that I'm not understanding is 1)
Why will an .ini file work for the definition but a config file won't 2)
Even if you must use an ini for the schema information, if you need to
dynamically choose 15 tables one at a time, since you are dynamically
creating the connection string with variables, why couldn't you use a config
file to load the respective path names and iteratively change the values for
each key? Or, if you don't know where those files will be in advance and
require user intervention, couldn't you just use a OpenFile Dialog box and
retrieve the file information from there?

Additionally, would it be possible to write the columnames as the first row
of each respective datafile and just set the HDR = YES and get the info from
there?

I guess what's confusing me is that you say ADO.NET needs an ini file to
create a DataTable, but you can create a datatable by simply instantiating
it and adding datacolumns to it. Similarly, that info can be inferred from
the first line. There are multiple ways to get there, and it seems like the
only problem is pointing to each file...which could be stored in a .config
file, another .ini or whatever else and just walk a loop substituting the
variables at each pass.

Maybe if I understood the ultimate goal and saw the code where you are
reading the .ini in I could be of more help.

Bill



have conditionally from
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top