Oh, and here's what you *really* wanted, an example
of writing to Access. (Sorry; it's been a long day.)
To do this, I use the strongly-typed datasets. You can
define one through the DataSet designer.
This goes through and changes all the entries in a table.
(I was just mucking around.) Then it adds 2 rows to the
table just for the heck of it.
Dim ds As CarriersDataSet = New CarriersDataSet
Dim adapter As CarriersTableAdapter = New CarriersTableAdapter
adapter.Fill(ds.Carriers)
For Each dr As DataRow In ds.Tables(0).Rows
Dim Carrier As String = dr.Item("c_Carrier").ToString
Console.WriteLine(String.Format("Carrier = '{0}'", Carrier))
Carrier &= "_x"
dr.Item("c_carrier") = Carrier
Next
'one way to add a row
Dim dr2 As DataRow = ds.Carriers.NewRow()
dr2("c_Carrier") = "Robin"
dr2("c_serv_ctr_code") = "RRR"
ds.Carriers.Rows.Add(dr2)
'another way to add a row
ds.Carriers.Rows.Add("SSS", "Scott")
'update the database with the changes to the dataset
adapter.Update(ds)
ds = Nothing
Again, this is VB2005/.Net2.0.
Robin S.
--------------------------------
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:YM******************************@comcast.com. ..
You can use the OLEDB objects
to read and write to an Access database.
Here's an example with VB2005/.Net2.0.
Imports System.Data.Oledb
Dim ConnectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\myAccessDatabase.mdb;" & _
"Persist Security Info=False"
Dim ds2 As DataSet = New DataSet
Dim conn As OleDbConnection = _
New OleDbConnection(ConnectionString)
conn.Open()
Dim cmd As OleDbCommand = _
New OleDbCommand("select * from Carriers", conn)
Dim adapter2 As OleDbDataAdapter = New OleDbDataAdapter(cmd)
adapter2.Fill(ds2, "Carriers")
For Each dr As DataRow In ds2.Tables(0).Rows
Dim Carrier As String = dr.Item("c_Carrier").ToString
Console.WriteLine(String.Format("Carrier = '{0}'", Carrier))
Next
conn.Close()
conn = Nothing
Robin S.
------------------------------
"gordy" <bp***@drexel.eduwrote in message
news:11********************@i12g2000cwa.googlegrou ps.com...
>Hey all,
I have a fairly simple app which goes out to the web to download
data.
I want to store this data in a database (1 table, ~8 fields or so).
My
program is written in VB.net and works fine to get the data. My
question is, how do I get the data into a database? I want to use
Microsoft Access.
I have seen several articles on using VB.net and ADO.net or Jet to
read
data in, but I haven't seen anything to write data out. Can anyone
suggest articles? Thanks,
Brian