好了,问题如下:C#Oracle数据库10g中发出
我使用C#WPF应用程序内置,我已经知道如何连接到Oracle数据库引擎,但我需要在它的一些帮助。
第一,我想知道如何将服务器添加到连接字符串...
OleDbConnection conn = new OleDbConnection("provider=MSDAORA;data source=ORCL;user id=SCOTT;password=TIGER");
是它的供应商或数据源?和服务器在我的电脑上,我应该写它localhost
或127.0.0.1
然后端口?以及如何添加端口是server:port
还是应该添加另一个参数?
第二,我创建了一个函数来执行发送给它的查询作为参数,我想把查询结果放在DataSet
但我不知道如何将结果转换为DataSet。
这是我的函数:
public DataSet SelectQuery(String p_sSql)
{
DataSet ds = new DataSet();
try
{
OleDbCommand myOleDbCommand = conn.CreateCommand();
myOleDbCommand.CommandText = p_sSql.ToString();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read();
//here I want to add the result to the DataSet ds ...
myOleDbDataReader.Close();
conn.Close();
return ds;
}
catch (System.Exception ex)
{
MessageBox.Show("Error: " + ex.ToString());
return null;
}
}
我按照第二个链接中提到的有关连接的说明,但我无法弄清楚我的数据库的正确连接字符串,我使用的是Oracle 10g XE,我不知道提供者和数据是什么来源应该是。 – sikas 2010-06-23 15:07:24
请查看:http://www.connectionstrings.com/oracle – Zeal 2010-06-25 18:27:16