我想从 oracle 数据库中获取多个数据并将其存储到 C# .net 中的另一个变量中。
我正在使用此代码。
public static void FetchData(string MeterSerialNumber, string MeterManufacturer, string MeterType, XmlDocument xmlReXML, string StartTime, string StopTime)
{
string Acctid = "";
string Ser = "";
string name1 = "";
string towns = "";
string Qry = "SELECT DISTINCT AC.ACCOUNTID as accid ,MT.SERIALNUMBER as srno,AC.NAME as names,OC.OPCONAME as town1,OC.CITY discm FROM ACCOUNT AC, XXMETERHIST M, LSMDPHYSICALMETER MT,LSSERVICEPOINT P,LSMDMTRMANUFACTURER MANUFAC,OPERATINGCOMPANY OC,LSMARKET LS WHERE AC.UIDACCOUNT = M.UIDACCOUNT AND M.UIDPHYSICALMETER = MT.UIDPHYSICALMETER and LS.MARKETID = OC.OPCOCODE and LS.UIDMARKET = P.UIDMARKET and MANUFAC.UIDMTRMANUFACTURER = MT.UIDMETERMANUFACTURER AND M.UIDSERVICEPOINT = P.UIDSERVICEPOINT and MT.SERIALNUMBER ='?' AND MT.UIDPHYSMTRTYPE = '43'";
OleDbConnection con = new OleDbConnection("provider=MSDAORA.oracle;user id=testapp;password=testapp;data source=mdmdb_tb");
DataTable dtbl = new DataTable();
OleDbDataAdapter dad = new OleDbDataAdapter(Qry, con);
dad.SelectCommand.Parameters.Add("?", OleDbType.VarChar).Value = MeterSerialNumber;
con.Open();
dtbl.Columns.Add("accid");
dtbl.Columns.Add("srno");
dtbl.Columns.Add("names");
dtbl.Columns.Add("town1");
dtbl.Columns.Add("discm");
dad.Fill(dtbl);
if (dtbl.Rows.Count > 0)
{
Acctid = (dtbl.Rows[0].ItemArray[0].ToString());
Ser = (dtbl.Rows[0].ItemArray[1].ToString());
name1 = (dtbl.Rows[0].ItemArray[2].ToString());
towns = (dtbl.Rows[0].ItemArray[3].ToString());
}
}
但是数据并没有保存在所有变量中。它抛出了boundrange异常的Indexout。