: Hi Guys. I am trying to export data from my Access DB to a CSV
: file. I have managed to get this work OK, however, I want to take
: this one step further in that I want to only export data in the DB
: that have a value of '0' in the "EXPORTED" Column. I have done the
: below in the export code but it gives me an error.
:
:
:
: //Write all records in the DB
: foreach (DataRow dr in dt.Rows)
: {
: if (dr["Exported"] == '0')
: {
: for (int i = 0; i < iColCount; i++)
: {
: if (!Convert.IsDBNull(dr[i]))
: {
: sw.Write(dr[i].ToString());
: }
: if (i < iColCount - 1)
: {
: sw.Write(",");
: }
: }
: }
:
: sw.Write(sw.NewLine);
:
:
: }
:
: sw.Close();
: :
:
: The error I get is as follows:
: "Operator '==' cannot be applied to the operands of type 'string'
: and 'char'
:
: Does anybody know how I can get past this?
:
There are 3 ways:
- Change the field-type into a char
- Dynamically get the first char of the string
- Change '0' into a string