Private Sub frmCust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
               dbSource = "Data Source=xx-B4C521B850\SQLEXPRESS;Initial Catalog=TT;Integrated Security=True"

        con.ConnectionString = dbSource
        con.Open()
        da.Dispose()
        sql = "Select * from Cust"
        da = New SqlClient.SqlDataAdapter(sql, con)

        da.Fill(ds, "Cust")
        da.Update(ds, "Cust")
        con.Close()
        MaxRows = ds.Tables("Cust").Rows.Count
        inc = -1
    End Sub

if after executing upper code the maxrows value is 10 after executing following code it becomes 21 how!!!!!!!!

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
       
                    con.Open()
            sql = "INSERT INTO Cust (Cust_Fn,Cust_Ln,Cust_Address,Cust_Mob,Cust_Land,Cust_CLand) VALUES ('" & txtFn.Text & "','" & txtLn.Text & "','" & txtAddress.Text & "','" & txtMob.Text & "','" & txtLand.Text & "','" & chkLCo.CheckState & "')"
            cmd = New SqlClient.SqlCommand(sql, con)
            cmd.ExecuteNonQuery()

            da.Update(ds, "Cust")
            MsgBox("New Record added to the Database")
da.Fill(ds, "Cust")
            con.Close()
            MaxRows1 = ds.Tables("Cust").Rows.Count
            inc = -1
        End If
    End Sub

PLS HELP

Simply because you are taking the count after adding more records.

Thanks for ur help!!

One more question is it possible to call form load event on button click

Following is the vb code i want same function in vb.net

Private Sub cmdaddcancel_Click()
       Form_Load
  End Sub

in vb we simply call Form_Load is it possible in vb.net

To call form2 you must to make an object of form2 :

Dim Myform as New Form2
    Myform.show

NOTE:---Please start a new thread for a new question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.