Inserting Issues

Joined
Aug 3, 2002
Messages
19
Hey All,

Im trying to pull this off but am getting a problem... this is the code snippet

ConnectToDatabase()
Try
myDataRow = myDataTable.NewRow()
myDataRow.BeginEdit()
myDataRow.Item("PatientID") = PatientIDTxt.Text
myDataRow("Name") = NameTxt.Text
myDataRow.EndEdit()
myDataTable.Rows.Add(myDataRow)
DAdapter.InsertCommand = commBuilder.GetInsertCommand
DAdapter.Update(myDataSet)
myDataTable.AcceptChanges()

the error reads: object reference not set to an instance of an object

ok i dont know what that means... me and vb.net havent had to time to get aquainted...

please help...

Thank You
 
Have you inialised your commandbuilder?

[
Code:
commBuilder = New System.Data.OleDbCommandBuilder(DAdapter)
 
Look at the line at which the error occured, you can know which object is causing the error, it could be your datatable, your dataset, your commBuilder or even your Dataadapter
 
Sorry, forgot to include the code ;)

if mydatatable is causing the error add

mydatatable = new datatable()

if mydataset is causing the error add

mydataset = new dataset()

if DAdapter is causing the error add

Dadapter is causing the error add

Dadapter = new Dadapter() although i suspect it could be the data adapter since you seem to have used it to get the data.

If it is the commbuilder then do as Hog told you.
 
Back
Top