hi peeps am a newbie and am using visual basic .net 2003. am trying to develope a windows application so that users and input data. the data will then be stored in a database, there will be two forms. the first with a button named "next page" ..when the user hits this button the information he/she inputted will be added to the database then form2 will load.. where he/she is required to input more data.. i go through wit some things .. when i hit the"next page" button page two loads but the data is not sent to the database.. this is my codes.. plz help..
Code:Imports System.Data Public Class Form1 Inherits System.Windows.Forms.Form Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim cb As New OleDb.OleDbCommandBuilder Dim dsNewRow As DataRow Dim MaxRows As Integer Dim inc As Integer Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextPage.Click con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Vern\My Documents\Database\database.mdb" con.Open() MsgBox("A Connection to the Database is now open") sql = "SELECT * FROM nigel" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "AddressBook") con.Close() MsgBox("The Connection to the Database is now Closed") MaxRows = ds.Tables("AddressBook").Rows.Count inc = -1 If inc <> -1 Then dsNewRow = ds.Tables("AddressBook").NewRow() dsNewRow.Item("Order") = txtOrder.Text ds.Tables("AddressBook").Rows.Add(dsNewRow) da.Update(ds, "AddressBook") MsgBox("New Record added to the Database") End If objForm1.Visible = False objForm2.ShowDialog() End Sub Private Sub NavigateRecords() txtOrder.Text = ds.Tables("AddressBook").Rows(inc).Item("order") End Sub End Class


Reply With Quote