fmartinez78ovi
Member
- Joined
- Sep 14, 2020
- Messages
- 11
- Programming Experience
- 5-10
Hi group,
I am trying to export from listbox to a text file, but I am getting next error message:
Can not convert from object type 'System.Data.DataRowView' to type 'System.String'
Error is on line 24.
My piece of code is as follow:
Any help or guidance will be really appreciated.
Thanks in advance.
Kind regards,
Francisco Mtz.
I am trying to export from listbox to a text file, but I am getting next error message:
Can not convert from object type 'System.Data.DataRowView' to type 'System.String'
Error is on line 24.
My piece of code is as follow:
C#:
using (OracleConnection con = new OracleConnection(oradb))
{
//create a new oledb dataadapter
con.Open();
OracleDataAdapter daTXT = new OracleDataAdapter("SELECT decode(c1, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c2, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c3, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c4, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c5, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c6, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c7, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c8, 'L', 'G', 'V', 'P', 'E') ||','|| decode(c9, 'L', 'G', 'V', 'P', 'E') ctotal FROM combina_final_2f7d_laluz where jornada = " + CmbJornada.Text + " and temporada = '" + CmbTemporada.Text + "' and pronosticador in ('FRANK1', 'FRANK2') order by desarrollo", con);
//create a new dataset
DataSet dsTXT = new DataSet();
//fill the datset
daTXT.Fill(dsTXT, "combinaciones_txt");
lstCombinaciones.DataSource = dsTXT.Tables["combinaciones_txt"];
lstCombinaciones.DisplayMember = "ctotal";
SaveFileDialog dlg = new SaveFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
StreamWriter writer = new StreamWriter(dlg.FileName);
for (int i = 0; i < lstCombinaciones.Items.Count; i++)
{
writer.WriteLine((string)lstCombinaciones.Items[i]);
}
writer.Close();
}
dlg.Dispose();
con.Close();
}
Any help or guidance will be really appreciated.
Thanks in advance.
Kind regards,
Francisco Mtz.