hi,
im trying to write to a ms access database using c#,however i keep running in to problems.
One is
A field initializer cannot reference the nonstatic field, method, or property 'Register.objConnection'
the other
A field initializer cannot reference the nonstatic field, method, or property 'Register.objMemberDA'
the code i am using is
OleDbConnection objConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0.....);
OleDbDataAdapter objMemberDA = new OleDbDataAdapter("select * from tblMember", objConnection);
OleDbCommandBuilder objMemberCB = new OleDbCommandBuilder(objMemberDA);
DataSet objDataSet = new DataSet();
protected void btnSubmit_Click(object sender, EventArgs e)
{
DataRow objRow;
objRow=objDataSet.Tables.Add("tblMember").NewRow();
objRow["Name"]= txtMemberName.Text;
objRow["Address1"] = txtAddress1.Text;
objRow["Address2"] = txtAddress2.Text;
objRow["Address3"] = txtAddress3.Text;
objRow["Telephone"] = txtTelephone.Text;
objRow["Mobile"] = txtMobile.Text;
objRow["Password"] = txtPassword.Text;
objRow["ConfirmPassword"] = txtConPassword.Text;
objDataSet.Tables.Add(objRow);
objMemberDA.Update(objDataSet, "tblMember");}
Thank you for your help
im trying to write to a ms access database using c#,however i keep running in to problems.
One is
A field initializer cannot reference the nonstatic field, method, or property 'Register.objConnection'
the other
A field initializer cannot reference the nonstatic field, method, or property 'Register.objMemberDA'
the code i am using is
OleDbConnection objConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0.....);
OleDbDataAdapter objMemberDA = new OleDbDataAdapter("select * from tblMember", objConnection);
OleDbCommandBuilder objMemberCB = new OleDbCommandBuilder(objMemberDA);
DataSet objDataSet = new DataSet();
protected void btnSubmit_Click(object sender, EventArgs e)
{
DataRow objRow;
objRow=objDataSet.Tables.Add("tblMember").NewRow();
objRow["Name"]= txtMemberName.Text;
objRow["Address1"] = txtAddress1.Text;
objRow["Address2"] = txtAddress2.Text;
objRow["Address3"] = txtAddress3.Text;
objRow["Telephone"] = txtTelephone.Text;
objRow["Mobile"] = txtMobile.Text;
objRow["Password"] = txtPassword.Text;
objRow["ConfirmPassword"] = txtConPassword.Text;
objDataSet.Tables.Add(objRow);
objMemberDA.Update(objDataSet, "tblMember");}
Thank you for your help