c# - Connecting to oracle Database wouldn't work -
i want connect oracle database visual studio , populate datagridview data. know oracle . have sid,username , password. code:
using oracle.dataaccess.client; private void form1_load(object sender, eventargs e) { var select = "select * tblproject"; conn.connectionstring = "data source=(description=" + "(address_list=(address=(protocol=tcp)(host=10.3.50.205)(port=1521)))" + "(connect_data=(server=dedicated)(sid=sid)));" + "user id=username;password=pass;"; } using (oracleconnection connection = new oracleconnection(conn.connectionstring)) { oracledataadapter adapter = new oracledataadapter(select, connection); try { connection.open(); var ds = new dataset(); adapter.fill(ds); datagridview1.readonly = true; datagridview1.datasource = ds.tables[0]; } catch (exception ex) { console.writeline(ex.message); } }
but connection wouldn't open? problem? thank you
there several dataconnectors on market. @ least microsoft, oracle , devart. connection strings not compatible. have pay attention when looking examples.
i use ezconnect whenever possible:
username/password@[//]host[:port][/service_name]
less type -> less errors. once had connect test system refused old syntax, accepted ezconnect. never figured out why.
Comments
Post a Comment