E
Eran.Yasso
Hi,
My app updates mdb file with no probelm. the problem starts if there's
a space on a column name(header consists from two words). I tried all
sorts of things. here is my code:
private void button1_Click(object sender, System.EventArgs e)
{
string ColumnHeader = "DTV_DOWN MAC",updatestr="myupdate";
System.Data.OleDb.OleDbConnection con = null;
System.Data.OleDb.OleDbCommand command = null;
string filename = @"C:\test.mdb";
DataSet ds = new DataSet();
try
{
con = new
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + filename);// + ";Extended
Properties=\"text;HDR=Yes;IMEX=1;FMT=Delimited\"");
string sql = "UPDATE DataTable SET '" + ColumnHeader + "' =
'"+updatestr+"' WHERE TBL_ID = 1980";
con.Open();
command = new OleDbCommand(sql,con);
int t = command.ExecuteNonQuery();
}
catch(Exception err)
{
MessageBox.Show(err.Message.ToString());
}
con.Close();
}
the exception occurs in line int "t = command.ExecuteNonQuery();".
i get error message "No value given for one or more requiered
parameter".
If i remove the space and use "_" in the mdb header and in
ColumnHeader,
it works. Can't I update MDB with space in header?
Thanks for the help.
My app updates mdb file with no probelm. the problem starts if there's
a space on a column name(header consists from two words). I tried all
sorts of things. here is my code:
private void button1_Click(object sender, System.EventArgs e)
{
string ColumnHeader = "DTV_DOWN MAC",updatestr="myupdate";
System.Data.OleDb.OleDbConnection con = null;
System.Data.OleDb.OleDbCommand command = null;
string filename = @"C:\test.mdb";
DataSet ds = new DataSet();
try
{
con = new
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + filename);// + ";Extended
Properties=\"text;HDR=Yes;IMEX=1;FMT=Delimited\"");
string sql = "UPDATE DataTable SET '" + ColumnHeader + "' =
'"+updatestr+"' WHERE TBL_ID = 1980";
con.Open();
command = new OleDbCommand(sql,con);
int t = command.ExecuteNonQuery();
}
catch(Exception err)
{
MessageBox.Show(err.Message.ToString());
}
con.Close();
}
the exception occurs in line int "t = command.ExecuteNonQuery();".
i get error message "No value given for one or more requiered
parameter".
If i remove the space and use "_" in the mdb header and in
ColumnHeader,
it works. Can't I update MDB with space in header?
Thanks for the help.