VB.NET - Binding Navigator

Asked By ronald
02-Aug-11 11:50 PM
There is an obvious problem with the Binding Navigator and DBNavigator. All I'm doing is adding a database to the application putting datagrid on a form and running the program.  The DBNavigator control is grayed out I have uninstalled reinstalled VS 2008, .Net 3.5 and it's still not working.  I believe it is a known problem throughout the VB development world is there a fix for this issue.

Thanks.
  James H replied to ronald
02-Aug-11 11:59 PM
Represents the navigation and manipulation user interface (UI) for controls on a form that are bound to data.

Adding a BindingNavigator control to a form and binding it to a data source, such as a http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx, will automatically establish the relationships in this table.

You can use one of the following techniques to customize this toolbar:

  • Create the BindingNavigator with the http://msdn.microsoft.com/en-us/library/ms158110.aspx constructor, which accepts a Boolean addStandardItems parameter, and set this parameter to false. Then add the desired http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem.aspx objects to the http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstrip.items.aspx collection.

  • If a great deal of customization is desired, or the custom design will be reused, derive a class from BindingNavigator and override the http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingnavigator.addstandarditems.aspx method to define additional or alternate standard items.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.Windows.Forms;
 
// This form demonstrates using a BindingNavigator to display
// rows from a database query sequentially.
public class Form1 : Form
{
  // This is the BindingNavigator that allows the user
  // to navigate through the rows in a DataSet.
  BindingNavigator customersBindingNavigator = new BindingNavigator(true);
 
  // This is the BindingSource that provides data for
  // the Textbox control.
  BindingSource customersBindingSource = new BindingSource();
 
  // This is the TextBox control that displays the CompanyName
  // field from the the DataSet.
  TextBox companyNameTextBox = new TextBox();
 
  public Form1()
  {
    // Set up the BindingSource component.
    this.customersBindingNavigator.BindingSource = this.customersBindingSource;
    this.customersBindingNavigator.Dock = DockStyle.Top;
    this.Controls.Add(this.customersBindingNavigator);
 
    // Set up the TextBox control for displaying company names.
    this.companyNameTextBox.Dock = DockStyle.Bottom;
    this.Controls.Add(this.companyNameTextBox);
 
    // Set up the form.
    this.Size = new Size(800, 200);
    this.Load += new EventHandler(Form1_Load);
  }
 
  void Form1_Load(object sender, EventArgs e)
  {
    // Open a connection to the database.
    // Replace the value of connectString with a valid
    // connection string to a Northwind database accessible
    // to your system.
    string connectString =
      "Integrated Security=SSPI;Persist Security Info=False;" +
      "Initial Catalog=Northwind;Data Source=localhost";
 
    using (SqlConnection connection = new SqlConnection(connectString))
    {
 
      SqlDataAdapter dataAdapter1 =
        new SqlDataAdapter(new SqlCommand("Select * From Customers",connection));
      DataSet ds = new DataSet("Northwind Customers");
      ds.Tables.Add("Customers");
      dataAdapter1.Fill(ds.Tables["Customers"]);
 
      // Assign the DataSet as the DataSource for the BindingSource.
      this.customersBindingSource.DataSource = ds.Tables["Customers"];
 
      // Bind the CompanyName field to the TextBox control.
      this.companyNameTextBox.DataBindings.Add(
        new Binding("Text",
        this.customersBindingSource,
        "CompanyName",
        true));
    }
  }
 
  [STAThread]
  public static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}

  Ravi S replied to ronald
03-Aug-11 12:05 AM
HI

try htis

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Path As String = System.IO.Directory.GetCurrentDirectory & "\GSD.mdb"
        Dim SQLStatement As String = "SELECT SupplierID, SupplierName, Address, ContactNo FROM Supplier"
        Dim Conn As OleDb.OleDbConnection
        Dim Comm As OleDb.OleDbCommand
        Try
            Conn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Path & "';Jet OLEDB:Database Password=")
            Comm = New OleDb.OleDbCommand(SQLStatement)
            Conn.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            End
        End Try
        Comm.Connection = Conn
        Dim dataAdapter As New OleDb.OleDbDataAdapter(Comm)
        Dim dataSet As New DataSet("Supplier")
        dataAdapter.Fill(dataSet, "Supplier")
        DataGridView1.DataSource = dataSet
        DataGridView1.DataMember = "Supplier"
    End Sub
End Class

refer the links also
http://stackoverflow.com/questions/2084636/bindingnavigator-in-vb-net-2008
http://www.developerfusion.com/thread/54011/binding-navigatorbinding-sourcedatagridview-how-to/
http://www.dreamincode.net/forums/topic/165595-binding-navigator/
  TSN ... replied to ronald
03-Aug-11 12:07 AM
Here are the steps I do to insert data into an MS Access db:

1.make new Datasource
2.Drag a table from DataSource sidebar in VS 2005 into a winForm
3.now we have a datagridview and a dbNavigator in the form
4. F5
5.enter new data into datagrid
6.Save button
7.check the mdb file---> no Data!!!
8. the eventhandler for Savebutton is correct
9. no errors
10. there is data in grid before application is terminated.

the very same proccess for SQL db is correct and is working properly.

follow this link-
  Radhika roy replied to ronald
03-Aug-11 11:27 AM

Follow these steps-

1.make new Datasource
2.Drag a table from DataSource sidebar in VS 2005 into a winForm
3.now we have a datagridview and a dbNavigator in the form
4. F5
5.enter new data into datagrid
6.Save button
7.check the mdb file---> no Data!!!
8. the eventhandler for Savebutton is correct
9. no errors
10. there is data in grid before application is terminated.

the very same proccess for SQL db is correct and is working properly.

follow this link-

http://bytes.com/topic/c-sharp/answers/487620-db-does-not-update-using-dbnavigator

Hope this will help you.
  Radhika roy replied to ronald
03-Aug-11 11:45 AM

Follow these steps-

1.make new Datasource
2.Drag a table from DataSource sidebar in VS 2005 into a winForm
3.now we have a datagridview and a dbNavigator in the form
4. F5
5.enter new data into datagrid
6.Save button
7.check the mdb file---> no Data!!!
8. the eventhandler for Savebutton is correct
9. no errors
10. there is data in grid before application is terminated.

the very same proccess for SQL db is correct and is working properly.

follow this link-

http://bytes.com/topic/c-sharp/answers/487620-db-does-not-update-using-dbnavigator
Create New Account
help
What are the basic steps involved in data access with ado.net in disconnected environment? OleDbDataAdapter (1) OleDbConnection (1) SqlDataAdapter (1) OleDbCommand (1) SqlConnection (1) SqlCommand (1) DataColumn (1) ADO.NET (1) Data access using the following steps: * Defining the connection string for the database server * Defining the connection (SqlConnection, OleDbConnection, etc) to the database using the connection string * Defining the command (SqlCommand, OleDbCommand, etc) or command string that contains the query * Defining the data adapter (SqlDataAdapter, OleDbDataAdapter, etc) using the command string and the connection object * Creating a new DataSet object * If
want to connect the database acess to c#.net . . . please send example coding for that OledbConnection con = new OledbConnection( "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C: \ mydatabase.mdb;" ); con.Open(); OledbCommand comm = new OledbCommand( "select * from Categories" , con); OledbDataAdapter da = new OledbDataAdapter(comm); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); dataGridView1.DataSource = dt; Hi, You can use the OleDbConnection and OleDbCommand objects to connect to an MS Access database and insert some records: OleDbConnection oleDbConnection = new OleDbConnection( " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C: \ db1.mdb" ); OleDbCommand oleDbCommand = new OleDbCommand
convert this code for sql server 2000 here are the code: / / create a oledb connection oleDbConnection cn = new oleDbConnection(sConnectionString); / / create data adapter oleDbdataAdapter adp = new oleDbdataAdapter( "select * from Categories" , cn); / / Create a Dataset DataSet ds = new DataSet(); adp.Fill(ds); / / NOW the display index for first item to be displayed ComboBox1.SelectedIndex = 0; Simply change your OleDbConnection and OleDbDataAdapter to SqlDbConnection and SqlDbDataAdapter and this should now work for SQL Server 2000. SQL Server System.Data.SqlClient; / / create a oledb connection SqlConnection cn = new SqlConnection (sConnectionString); / / create data adapter SqlDataAdapter adp = new SqlDataAdapter ( "select * from Categories" , cn); / / Create a Dataset DataSet ds = new DataSet (); adp.Fill(ds, "Categories
from tables in two different *.mdb files? You should also specify the UpdateCommand of the OleDBDataAdapter and then execute it by calling the da.Update method. There is an example of how this can be done in the MSDN: OleDbDataAdapter.OleDbDataAdapter(String, OleDbConnection) Constructor Hi, The following code example populates a list of customers from the Northwind database customer / / Assumes that customerConnection is a valid SqlConnection object. / / Assumes that orderConnection is a valid OleDbConnection object. SqlDataAdapter custAdapter = new SqlDataAdapter( "SELECT * FROM dbo.Customers" , customerConnection); OleDbDataAdapter ordAdapter = new OleDbDataAdapter( "SELECT * FROM Orders" , orderConnection); DataSet customerOrders = new DataSet(); custAdapter.Fill(customerOrders, "Customers
System.EventArgs e) { / / Put user code to initialize the page here / / Create an object of OleDbDataAdapter OleDbDataAdapter da = new OleDbDataAdapter( "Select * from Employees" , "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C: \ Program Files \ Microsoft value member cbCust.DataSource = dsView; cbCust.DisplayMember = "Customers.CompanyName" ; cbCust.ValueMember = "Customers.CustomerID" ; void bindDropDonw() { SqlDataAdapter da = new SqlDataAdapter ( "select empid from emp" , "ConnectionString" ); DataTable dt = new DataTable (); da.Fill(dt); / / Fill the dataset SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[ "CON" ].ConnectionString)) { string Query = "select productid, productname from products" ; SqlDataAdapter da = new SqlDataAdapter(Query, con); DataTable dtProducts = new DataTable( "ProductsTable" ); da.Fill(dtProducts); lst.DataTextField = textField; lst.DataValueField Con.Open(); / / Command Text String sSQLCmdText = "Select * from Customers"; / / Create a new SQL Data Adapter SqlDataAdapter DA = new SqlDataAdapter(sSQLCmdText , Con); DataSet DS = new DataSet("PlayerDS"); / / DataSet DA.Fill(DS, "Player