我有一個名爲「Sistema的」使用應用頂點Express數據庫,我想用這個代碼連接:連接到Oracle APEX數據庫在C#
private void button1_Click(object sender, EventArgs e)
{
string constr = "Data Source=sistema;User Id=admin;Password=123;";
string ProviderName = "Oracle.ManagedDataAccess.Client";
using (OracleConnection conn = new OracleConnection(constr))
{
try
{
conn.ConnectionString = constr;
conn.Open();
//Get all the schema collections and write to an XML file.
//The XML file name is Oracle.ManagedDataAccess.Client_Schema.xml
DataTable dtSchema = conn.GetSchema();
dtSchema.WriteXml(ProviderName + "_Schema.xml");
MessageBox.Show("YEAH");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show(ex.StackTrace);
}
}
}
這段代碼演示了我這個錯誤:
ORA-12154: TNS could not resolve the specified connection identified
有了這個新代碼:
private void button1_Click(object sender, EventArgs e)
{
string constr = @"Data Source=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SISTEMA)));
User Id=ADMIN ;Password=123";
string ProviderName = "Oracle.ManagedDataAccess.Client";
using (OracleConnection conn = new OracleConnection(constr))
{
try
{
conn.ConnectionString = constr;
conn.Open();
//Get all the schema collections and write to an XML file.
//The XML file name is Oracle.ManagedDataAccess.Client_Schema.xml
DataTable dtSchema = conn.GetSchema();
dtSchema.WriteXml(ProviderName + "_Schema.xml");
MessageBox.Show("YEAH");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show(ex.StackTrace);
}
}
}
它返回我
User id 'is an invalid connection string attribute
當我嘗試連接到由VS數據庫中我得到這個錯誤:
The listener does not currently know the requested service
數據庫工作正常上的Oracle APEX http://localhost:8080/apex並具有表和創建 記錄也有大寫和小寫名稱,並嘗試沒有什麼變化
我不明白如何在應用程序表達式中連接到我的Oracle Apex數據庫,這很令人困惑,我不知道在oracle中正常的數據庫會發生什麼變化。
我該如何連接到我在c#中的apex數據庫?
我不確定,但嘗試'User ID'而不是'User Id'並從連接字符串中刪除任何空格字符。 –