Hi Developer,
I am tring to run multiple sql statements in dataset.
My code is:
public static DataSet Getdataset1(string filename1)
{
string Connectionstring = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Text;",
Path.GetDirectoryName(filename1));
string cmdstring = string.Format(@"select * FROM {0} order by IN_no desc,FIRST_DATE asc,END_DATE asc", Path.GetFileName(filename1));
string cmdstring1 = string.Format(@"select * FROM {0} order by IN no desc,FIRST DATE asc,END DATE asc",
Path.GetFileName(filename1));
string cmdstring2 = string.Format(@"select * FROM {0} order by Pd_no desc,FIRST_DATE asc,END DATE asc", Path.GetFileName(filename1));
DataSet dataset = new DataSet();
using (OleDbConnection olconn = new OleDbConnection(Connectionstring))
{
olconn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(cmdstring, olconn);
adapter.SelectCommand= new OleDbCommand(cmdstring1, olconn);
adapter.SelectCommand= new OleDbCommand(cmdstring2, olconn);
dataset.Clear();
adapter.Fill(dataset, "Test");
olconn.Close();
}
return dataset;
}
public void Process_Click(object sender, EventArgs e)
{
try
{
DataSet dataset = Form1.Getdataset1(Locations.Text);
Datagidveiw1.DataSource = dataset.Tables[0].DefaultView;
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
The error occurs when I want to sort data.
{"IErrorInfo.GetDescription failed with E_FAIL(0x80004005)."}
Actually I want to create a match condition between
cmdstring
and after match the headertext of columns and then only one sql statement is run to sort data.
How can I create that, any suggestions?
Please accept this request