If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Wanted: help with minimal ADO.NET in VS 2008
I have created a simple three column database where the first column is
auto-increment. Can someone help me change my program so that it reads the entire table and appends a new row and saves that new row in the mdb file? I'm trying to use a strongly typed dataset called DataSet3 and the line 28 never executes. It just skips to line 30. Can someone tell me what I am doing wrong? Thanks, Siegfried 1 Imports System.Data.OleDb 2 Imports System.Data.Odbc 3 Imports System.Data.Sql 4 5 Module DisconnectedRS 6 Dim outp As System.IO.TextWriter = System.Console.Out 7 Dim inp As System.IO.TextReader = System.Console.In 8 Sub Main(args() as String) 9 Dim arg as String 10 For Each arg in args 11 outp.WriteLine(" arg = " & arg) 12 Next 13 Dim cs As String 14 cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=simple.mdb;User Id=admin;Password=;" 15 Dim conn As New OleDb.OleDbConnection(cs) 16 conn.Open() 17 Dim sel As New String("SELECT * FROM SIMPLE") 18 Dim cmd As New OleDbCommand() 19 20 Dim ds As New DataSet3() 21 Dim da As New OleDbDataAdapter(sel, cs) 22 23 da.Fill(ds) 24 Dim r As DataSet3.descriptionRow 25 Dim t As DataSet3.descriptionDataTable 26 t = ds.description 27 For Each r In t 28 outp.WriteLine(r.sDescription & "," & r.dtCreation) 29 Next 30 r = t.NewRow 31 r.dtCreation = New DateTime(2008, 6, 18) 32 r.sDescription = "Sari" 33 ds.description.AcceptChanges() 34 End Sub 35 End Module |
#2
|
|||
|
|||
Wanted: help with minimal ADO.NET in VS 2008
Siegfried Heintze schrieb:
Can someone help me change my program so that it reads the entire table and appends a new row and saves that new row in the mdb file? hmm... 25 Dim t As DataSet3.descriptionDataTable 26 t = ds.description Does this really fill your table? Is there a t.Count or any similar property which gives you the number of records within your t? mfG -- stefan -- |
#3
|
|||
|
|||
Wanted: help with minimal ADO.NET in VS 2008
Yeah -- that is the problem: t.Rows.Count is zero. I checked it. Why? What am
I doing wrong? "Stefan Hoffmann" wrote: Siegfried Heintze schrieb: Can someone help me change my program so that it reads the entire table and appends a new row and saves that new row in the mdb file? hmm... 25 Dim t As DataSet3.descriptionDataTable 26 t = ds.description Does this really fill your table? Is there a t.Count or any similar property which gives you the number of records within your t? mfG -- stefan -- |
#4
|
|||
|
|||
Wanted: help with minimal ADO.NET in VS 2008
I can make this work with late bound data sets but not early bound. Can
someone tell me why? Thanks, Siegfried |
#5
|
|||
|
|||
Wanted: help with minimal ADO.NET in VS 2008
hi Siegfried,
Siegfried Heintze wrote: Yeah -- that is the problem: t.Rows.Count is zero. I checked it. Why? What am I doing wrong? Just a look at to OH for da.Fill(). It seems that you need the parameter srcTable. So da.Fill(ds, "simple") works as intended. mfG -- stefan -- |
Thread Tools | |
Display Modes | |
|
|