J
jbardrof
Okay so i'm having some trouble with adding to my database through the
dataset. i can read from it and it prints just fine, i run the code
okay with no errors, but it simply doesn't add the record, i've left
it simple here just so i can get it right before i start adding the
extra functionality. okay so the table name is UserID, and i want to
add into the table, what am i doing wrong?
private void btnAddRecord_Click(object sender, System.EventArgs
e)
{
OleDbConnection AddConnection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\salesleadmgmt.mdb");
OleDbDataAdapter addAdapter = new OleDbDataAdapter("Select *
from UserID", AddConnection);
DataSet addSet = new DataSet();
DataRow addRow;
OleDbCommandBuilder addCommandBuilder = new
OleDbCommandBuilder(addAdapter);
addAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
addAdapter.Fill(addSet, "UserID");
Console.WriteLine("i was able to load the userid
table.");
addRow = addSet.Tables["UserID"].NewRow();
addRow["UsrName"] = "Bob";
addRow["passwr"] = "Bobpwd";
addRow["UsrID"] = "6";
addSet.Tables["UserID"].Rows.Add(addRow);
Console.WriteLine("i inserted the new values");
}
this runs in the .CS file, i don't get any of the write lines or
anything, it does run on a button click, i have another button click
that works fine, i'll show that one, whats wrong with this first
one?
working display click
[code:1:e515321317]
private void Button1_Click(object sender, System.EventArgs e)
{
string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\salesleadmgmt.mdb";
OleDbConnection CustConnection = new
OleDbConnection(ConnectString);
CustConnection.Open();
DataSet CustSet = new DataSet();
OleDbDataAdapter CustAdapt = new OleDbDataAdapter("SELECT *
FROM CustInfo", CustConnection);
CustAdapt.Fill(CustSet);
CustConnection.Close();
CustGrid.DataSource = CustSet;
CustGrid.DataBind();
}
[/code:1:e515321317]
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
dataset. i can read from it and it prints just fine, i run the code
okay with no errors, but it simply doesn't add the record, i've left
it simple here just so i can get it right before i start adding the
extra functionality. okay so the table name is UserID, and i want to
add into the table, what am i doing wrong?
private void btnAddRecord_Click(object sender, System.EventArgs
e)
{
OleDbConnection AddConnection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\salesleadmgmt.mdb");
OleDbDataAdapter addAdapter = new OleDbDataAdapter("Select *
from UserID", AddConnection);
DataSet addSet = new DataSet();
DataRow addRow;
OleDbCommandBuilder addCommandBuilder = new
OleDbCommandBuilder(addAdapter);
addAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
addAdapter.Fill(addSet, "UserID");
Console.WriteLine("i was able to load the userid
table.");
addRow = addSet.Tables["UserID"].NewRow();
addRow["UsrName"] = "Bob";
addRow["passwr"] = "Bobpwd";
addRow["UsrID"] = "6";
addSet.Tables["UserID"].Rows.Add(addRow);
Console.WriteLine("i inserted the new values");
}
this runs in the .CS file, i don't get any of the write lines or
anything, it does run on a button click, i have another button click
that works fine, i'll show that one, whats wrong with this first
one?
working display click
[code:1:e515321317]
private void Button1_Click(object sender, System.EventArgs e)
{
string ConnectString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\salesleadmgmt.mdb";
OleDbConnection CustConnection = new
OleDbConnection(ConnectString);
CustConnection.Open();
DataSet CustSet = new DataSet();
OleDbDataAdapter CustAdapt = new OleDbDataAdapter("SELECT *
FROM CustInfo", CustConnection);
CustAdapt.Fill(CustSet);
CustConnection.Close();
CustGrid.DataSource = CustSet;
CustGrid.DataBind();
}
[/code:1:e515321317]
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*