C
Chriz Yuen
Sub Button1_Click(sender As Object, e As EventArgs)
Dim ConnectionString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & server.mappath("EzySys.mdb") & ";"
Dim myConn As New OleDbConnection(ConnectionString)
Dim myDataAdapter As New OleDbDataAdapter()
dim mySQL = "select * from resident_info"
myDataAdapter.SelectCommand = New OleDbCommand(mySQL, myConn)
Dim custCB As OleDbCommandBuilder = New
OleDbCommandBuilder(MyDataAdapter)
myConn.Open()
Dim DS As DataSet = New DataSet
myDataAdapter.Fill(DS)
Dim table As DataTable
Dim newRow As DataRow
' Code to modify data in DataSet here
table=DS.Tables("Resident_Info")
newRow=table.NewRow()
newRow("Resident_ID")="SL100"
table.Rows.add(newRow)
myConn.Close()
End Sub
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Dim ConnectionString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & server.mappath("EzySys.mdb") & ";"
Dim myConn As New OleDbConnection(ConnectionString)
Dim myDataAdapter As New OleDbDataAdapter()
dim mySQL = "select * from resident_info"
myDataAdapter.SelectCommand = New OleDbCommand(mySQL, myConn)
Dim custCB As OleDbCommandBuilder = New
OleDbCommandBuilder(MyDataAdapter)
myConn.Open()
Dim DS As DataSet = New DataSet
myDataAdapter.Fill(DS)
Dim table As DataTable
Dim newRow As DataRow
' Code to modify data in DataSet here
table=DS.Tables("Resident_Info")
newRow=table.NewRow()
newRow("Resident_ID")="SL100"
table.Rows.add(newRow)
myConn.Close()
End Sub
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.