Okay this question is so basic it is probably in my book head first c#, but alas I am lazy :) Actually I read it and sort of understand and sort of don't. Here is what I have.
I am trying to save data to a database on a button push but the variables seem to be private by the nature of where they are defined. I have tried to move where they are defined, but this seems to produce other errors. I am sure someone can answer this in under 5 seconds and I do appreciate the help. Plus I know stackoverflow won't turn into a flame war becasue the question is so stupid.
Also if you are feeling genourous if you could explain to me (and others who see this behind me) not just how to fix it but why it was fixed that way. The code follows.
namespace enable
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
OleDbConnection favouriteConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\192.168.123.5\\Share\\Matt\\BugTypes.mdb");
string strSQL = "SELECT CategoryName, Show " + "FROM [Categories] WHERE Show = 'Yes' " + "ORDER BY CategoryName";
OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, favouriteConnection);
OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(adapter);
DataTable dTable = new DataTable();
adapter.Fill(dTable);
BindingSource bSource = new BindingSource();
bSource.DataSource = dTable;
dataGridView1.DataSource = bSource;
adapter.Update(dTable);
}
private void button1_Click(object sender, EventArgs e)
{
adapter.Update(dTable);//this is the button that needs to do the save, but can't see the variables.
}
}
}