1
我想從使用c#的oracle數據庫中獲取數據。我正在使用System.Data.OracleClient.dll,但由於這已經過時,我決定將其更改爲System.Data.Oledb。 我的連接:OledbException row-00001無法分配內存
connection = new OleDbConnection();
connection.ConnectionString = string.Format("Provider=OraOLEDB.Oracle;Data Source={0};User ID={1};Password=23};", source, user, password);
這裏是我的方法獲取數據:
public ContactInfo GetInfo(string telnr)
{
connection.Open();
Console.WriteLine("OracleState: {0}", connection.State);
OleDbCommand command = connection.CreateCommand();
string sql = @"Select t1.bed_bedrijfsnr
, t1.pers_persoonsnr
, REPLACE(REPLACE(REPLACE(REPLACE(t1.telefoonnr, ' ', ''), '-', ''), '(', ''), ')', '') as telnr
, REPLACE(REPLACE(REPLACE(REPLACE(t1.gsmnr, ' ', ''), '-', ''), '(', ''), ')', '') as gsmnr
, t1.e_mail
, t2.synoniem
, t2.sales_coordinator
From table1 t1
, table2 t2
Where t1.bed_bedrijfsnr = t2.bedrijfsnr
And (REPLACE(REPLACE(REPLACE(REPLACE(t1.telefoonnr, ' ', ''), '-', ''), '(', ''), ')', '') = :tel Or REPLACE(REPLACE(REPLACE(REPLACE(t1.gsmnr, ' ', ''), '-', ''), '(', ''), ')', '') = :tel);";
command.CommandText = sql;
command.Parameters.Add(new OleDbParameter(":tel", telnr));
ContactInfo c = null;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
//readdata
}
reader.Close();
connection.Close();
Console.WriteLine("Oracle State: {0}", connection.State);
return c;
}
當我改變SQL語句「從表1中選擇*」它的工作原理,但這種說法我Visual Studio的說'OledbException row-00001 can not allocate memory'on'OleDbDataReader reader = command.ExecuteReader();'