![]() |
Click here to advertise with us
|
|
|||||||
| OLEDB Topics related to OLEDB with VB.NET |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
I am very new to vb.net and still trying to get my head around it. I am trying to connect to an access db and then update a table with some test info my code is: Code:
Dim con As New OleDb.OleDbConnection
Dim sql As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim MakeTableSQL As String
Dim MySql As String
Dim MySql2 As String
Dim MySql3 As String
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\email.mdb"
sql = "SELECT * FROM Email"
da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Labels").NewRow()
dsNewRow.Item("Body") = "Test"
ds.Tables("Labels").Rows.Add(dsNewRow)
da.Update(ds, "Labels")
MsgBox("New Record added to the Database")
i wondered if anyone could help? |
|
|||
|
your problem seems simple, i guess you have only forgotten to create an instance of DataRow : drow = new datarow
unable to create an instance of an object will issue a nullreference exception hope this would be helpful |
|
|||
|
Quote:
You're trying to access a table that doesn't exist. The dataset contains no tables. Tables("Label") will give you a nullreference exception. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|