Database name is TEST, user name test, pass test1234
I create fake acocunt, conection to db work
Data are located ond next loaction:
When connected do db OTHER USERS/MASTER/Table1
How to read that data to datarid?
I try this cod and have error: NETWORK LIBRARY: Name-Value syntax error
Error number: ORA-00303
C#
private void TABLE_fill()
{
String connectionString = "Data Source=("
+ " TEST = "
+ " (DESCRIPTION = "
+ " (ADDRESS = (PROTOCOL = TCP)(HOST = test.localdomain.intra)(PORT = 1521)) "
+ " (CONNECT_DATA = "
+ " (SERVICE_NAME = TEST) "
+ " (INSTANCE_NAME = TEST) "
+ " ) "
+ " ) "
+ " User Id=test; password=test1234; ";
OracleConnection con = new OracleConnection();
con.ConnectionString = connectionString;
con.Open();
OracleCommand cmd= new OracleCommand();
cmd.CommandText = "select * from Table1";
cmd.Connection= con;
cmd.CommandType = CommandType.Text;
//cmd.ExecuteNonQuery();
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.Load(dr);
ListDataGridView.DataSource = dataTable;
ListDataGridView.Update();
ListDataGridView.Refresh();
}
Prasad RaveendranRank #320 · 7.8K reputationPosted Oct 25, 2023, 4:43 PM EDT
The error you're encountering, "NETWORK LIBRARY: Name-Value syntax error," is likely due to an issue with your connection string. The connection string you provided has a couple of issues. You should use the correct format for Oracle connection strings. Try the following corrected code:
private void TABLE_fill() { string connectionString = "User Id=test;Password=test1234;Data Source=(DESCRIPTION=" + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=test.localdomain.intra)(PORT=1521)))" + "(CONNECT_DATA=(SERVICE_NAME=TEST)))"; OracleConnection con = new OracleConnection(connectionString); con.Open(); OracleCommand cmd = new OracleCommand("SELECT * FROM OTHER_USERS.MASTER.Table1", con); OracleDataReader dr = cmd.ExecuteReader(); System.Data.DataTable dataTable = new System.Data.DataTable(); dataTable.Load(dr); ListDataGridView.DataSource = dataTable; ListDataGridView.Update(); ListDataGridView.Refresh(); con.Close(); }In the corrected code:
SELECT * FROM OTHER_USERS.MASTER.Table1.Please replace
"OTHER_USERS"and"MASTER"with the actual schema and table names that you want to access in your database. Make sure your Oracle client and Oracle Data Provider for .NET are correctly installed and configured as well.