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.Ole Db
Sub AddInitialRecor ds()
'Create Connection String
Dim myConnectionStr ing As String =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
SystemFileDB & FileDBExtention
'Create the Connection
Dim myConnection As New OleDbConnection () '= New OleDbConnection ()
' ADODB.Connectio n()
MyConnection.Co nnectionString = myConnectionStr ing
myConnection.Op en()
'Whats the difference ? - Im assuming nothing for now
'Dim myDataAdapter As OleDbDataAdapte r = New
OleDbDataAdapte r("Select * From DBVersion", MyConnection)
'Create the Data Adapter
Dim myDataAdapter As New OleDbDataAdapte r("Select * From DBVersion",
MyConnection)
'Creates a Dataset Object and Fills with Data
'Create new Dataset
Dim myDataSet As New DataSet()
'Fill The Dataset
myDataAdapter.F ill(myDataSet, "DBVersion" )
'Now lets try to write a record into one field of this Table.
Dim NewVersionRow As DataRow = myDataSet.Table s("DBVersion"). NewRow
NewVersionRow(" CurVersion") = "2.00"
myDataSet.Table s("DBVersion"). Rows.Add(NewVer sionRow)
'Crashes but because its remmed out it may be why i dont actually add a
datarow.
'myDataAdapter. Update(myDataSe t, "DBVersion" )
myDataSet.Table s("DBVersion"). AcceptChanges()
myConnection.Cl ose()
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.Ole Db
Sub AddInitialRecor ds()
'Create Connection String
Dim myConnectionStr ing As String =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & _
SystemFileDB & FileDBExtention
'Create the Connection
Dim myConnection As New OleDbConnection () '= New OleDbConnection ()
' ADODB.Connectio n()
MyConnection.Co nnectionString = myConnectionStr ing
myConnection.Op en()
'Whats the difference ? - Im assuming nothing for now
'Dim myDataAdapter As OleDbDataAdapte r = New
OleDbDataAdapte r("Select * From DBVersion", MyConnection)
'Create the Data Adapter
Dim myDataAdapter As New OleDbDataAdapte r("Select * From DBVersion",
MyConnection)
'Creates a Dataset Object and Fills with Data
'Create new Dataset
Dim myDataSet As New DataSet()
'Fill The Dataset
myDataAdapter.F ill(myDataSet, "DBVersion" )
'Now lets try to write a record into one field of this Table.
Dim NewVersionRow As DataRow = myDataSet.Table s("DBVersion"). NewRow
NewVersionRow(" CurVersion") = "2.00"
myDataSet.Table s("DBVersion"). Rows.Add(NewVer sionRow)
'Crashes but because its remmed out it may be why i dont actually add a
datarow.
'myDataAdapter. Update(myDataSe t, "DBVersion" )
myDataSet.Table s("DBVersion"). AcceptChanges()
myConnection.Cl ose()
End Sub
Comment