Hi all, I am able to save, update, delete etc to data in already existing tables, but i can't seem to work out how to create and save a new table to a database. Using Visual Studio 2005, VB.
I've tried this and few other ways of coding it, but i can't seem to get it right:
__________________________________________________ ____
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New OleDb.OleDbDataAdapter
Dim dr As New DataRowAction
Dim dc As New DataColumn
Dim sql As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dt.TableName = "NewTableTest1"
dt.Columns.Add(dc)
dt.Rows.Add(dr)
ds.Tables.Add(dt)
da.Update(ds)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Andrew\AFL2008ScheduleNEW.mdb"
con.Open()
sql = "SELECT * FROM AndrewsPicks"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AFL2008ScheduleNEW")
End Sub
End Class
__________________________________________________ __
Error for this code = InvalidOperationException, refering to the code "da.Update(ds)"
Can't seem to find examples of what im looking for anywhere, any help would be appreciated.
cheers,
-Andrew