2
Answers

Simple data access using Access 2003 and VB.net

ricky_oswald

ricky_oswald

20y
1.6k
1
I have been trying for a while to connect some text boxes with fields of data in an Access 2003 database. I have read several documents on storing data such as images or storing/loading text from list boxes, combo boxes and such but I cannot seem to find anything relating to simply loading and saving information between text boxes and Access 2003 tables. Any form of help would be greatly appreciated.
Answers (2)
0
Daniel

Daniel

NA 4 9.9k 14y
        private void cmdSearch_Click(object sender, EventArgs e)
        {
            SqlConnection sqlNWConn = new SqlConnection();
            SqlDataAdapter daCustomers;
            DataSet dsCustomers;
            String tableName = "Customers";

            sqlNWConn = new SqlConnection(@"Data Source=DANS-MAC--WIN7\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");

                    if (radioAll.Checked == true)
                    {
                        try
                        {
                            sqlNWConn.Open();
                            dsCustomers = new DataSet();                                                // Creates a new DataSet
                            daCustomers = new SqlDataAdapter("select * from Customers", sqlNWConn);     // Creates a new SqlDataAdapter with select command and connection
                            SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daCustomers);             // Fills in insert, update, and delete commands
                            daCustomers.Fill(dsCustomers, tableName);                                   // Fills the dataset
                            dataGridCustomers.DataSource = dsCustomers;
                            dataGridCustomers.DataMember = tableName;
                        }
                        catch
                        {
                            MessageBox.Show("there was an error and your code is crap"); // error will be changed when working
                        }
                    }

                    if (radioName.Checked == true)
                    {
                          // Searches value in txtSearch in table Customer ContactName
                    }
          }
0
Sam Hobbs

Sam Hobbs

NA 28.7k 1.3m 14y
You seem to be feeling panicked. Have a little fun with Database Table Update in a DataGridView without Writing Code.