Hi John,
As told above simple (I have made the access database in this sample, that
is the major part, while I as well have used the dataset which comes direct
from the Access database to keep the sample simple)
I hope this helps?
Cor
\\\
'Needs a form with 2 buttons
'set a reference to ado ext 2.7 for blabla
Private conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\db1.mdb;User Id=admin;Password=;")
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
da.Fill(ds)
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
ds.Tables(0).Rows(0)(1) = 1
ds.Tables(0).Rows(0)(2) = "Holland"
Dim ws As New localhost.DataBaseUpdate
ws.SetDataset(ds)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
Dim da As New OleDb.OleDbDataAdapter("Select * from countries",
conn)
Dim ds As New DataSet
Dim cmd As New OleDb.OleDbCommandBuilder(da)
Dim ws As New localhost.DataBaseUpdate
ds = ws.GetDataset()
da.Update(ds)
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\db1.mdb")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE countries ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub
///
\\\
<WebMethod()> _
Public Function GetDataset() As DataSet
Dim ds As New DataSet
ds.ReadXml("C:\wsTest.xml")
Return ds
End Function
<WebMethod()> _
Public Sub SetDataset(ByVal ds As DataSet)
ds.WriteXml("C:\wsTest.xml", XmlWriteMode.WriteSchema)
End Sub
///
,
You can just move it into the dataset of the acces file, or when the dataset
is equal to the access table you can even insert it. I do not believe in
that because when you than does that twice you have a constraint error. I
think it is better just to get the item from the dataset and set that in the
with the key readed access datatable and than update that.
Than you can update when it exist and insert it when it is new using the
normal dataadapter technique.
However where comes your data from, than I can maybe make a sample what
looks something more like that.
However I am writing this while you no that there is EK, so I review this
tomorrow when this is a problem. Message that than.
In my opinion it is even easier to put it in an Access file than
writting
it
to disk.
A pity you did not answer earlier, I am busy tomorrow when I have time I
will try to give you an example of that tomorrow but that will than not
early
(When you do not need that message that than)
Cor
store
the table
too? it
uses