M
Miro
Im a VB Newbie so I hope I'm going about this in the right direction.
I have a simple DB that has 1 Table called DBVersion and in that table the
column is CurVersion ( String )
Im trying to connect to the db, and then add a record to the DBVersion
table.
Except I cant.
I have 1 line that crashes and if i rem it out it works but nothing gets
added.
Can someone have a peek to let me know what im missing or doing wrong.
Thanks,
Miro
====Code
Imports System.Data
Imports System.Data.OleDb
Sub AddInitialRecords()
'Create Connection String
Dim myConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
SystemFileDB & FileDBExtention
'Create the Connection
Dim myConnection As New OleDbConnection() '= New OleDbConnection()
' ADODB.Connection()
MyConnection.ConnectionString = myConnectionString
myConnection.Open()
'Whats the difference ? - Im assuming nothing for now
'Dim myDataAdapter As OleDbDataAdapter = New
OleDbDataAdapter("Select * From DBVersion", MyConnection)
'Create the Data Adapter
Dim myDataAdapter As New OleDbDataAdapter("Select * From DBVersion",
MyConnection)
'Creates a Dataset Object and Fills with Data
'Create new Dataset
Dim myDataSet As New DataSet()
'Fill The Dataset
myDataAdapter.Fill(myDataSet, "DBVersion")
'Now lets try to write a record into one field of this Table.
Dim NewVersionRow As DataRow = myDataSet.Tables("DBVersion").NewRow
NewVersionRow("CurVersion") = "2.00"
myDataSet.Tables("DBVersion").Rows.Add(NewVersionRow)
'Crashes but because its remmed out it may be why i dont actually add a
datarow.
'myDataAdapter.Update(myDataSet, "DBVersion")
myDataSet.Tables("DBVersion").AcceptChanges()
myConnection.Close()
End Sub
I have a simple DB that has 1 Table called DBVersion and in that table the
column is CurVersion ( String )
Im trying to connect to the db, and then add a record to the DBVersion
table.
Except I cant.
I have 1 line that crashes and if i rem it out it works but nothing gets
added.
Can someone have a peek to let me know what im missing or doing wrong.
Thanks,
Miro
====Code
Imports System.Data
Imports System.Data.OleDb
Sub AddInitialRecords()
'Create Connection String
Dim myConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
SystemFileDB & FileDBExtention
'Create the Connection
Dim myConnection As New OleDbConnection() '= New OleDbConnection()
' ADODB.Connection()
MyConnection.ConnectionString = myConnectionString
myConnection.Open()
'Whats the difference ? - Im assuming nothing for now
'Dim myDataAdapter As OleDbDataAdapter = New
OleDbDataAdapter("Select * From DBVersion", MyConnection)
'Create the Data Adapter
Dim myDataAdapter As New OleDbDataAdapter("Select * From DBVersion",
MyConnection)
'Creates a Dataset Object and Fills with Data
'Create new Dataset
Dim myDataSet As New DataSet()
'Fill The Dataset
myDataAdapter.Fill(myDataSet, "DBVersion")
'Now lets try to write a record into one field of this Table.
Dim NewVersionRow As DataRow = myDataSet.Tables("DBVersion").NewRow
NewVersionRow("CurVersion") = "2.00"
myDataSet.Tables("DBVersion").Rows.Add(NewVersionRow)
'Crashes but because its remmed out it may be why i dont actually add a
datarow.
'myDataAdapter.Update(myDataSet, "DBVersion")
myDataSet.Tables("DBVersion").AcceptChanges()
myConnection.Close()
End Sub