how to set schema in ado.net

Posted by Srinup97 under ADO.NET on 9/3/2013 | Points: 10 | Views : 3302 | Status : [Member] | Replies : 5
Hi

Iam connecting to db2 database i have a problem that i will going to schema in after connection opening
i want to set the schema

iam connecting to the db2 database in this database different schemas are there.
I want to connect to connect particular schema only,
i tried that in connection string we cant give the schema,
After connection opening only we have to set the schema,
i have a code that i.e by using connect to the active data object(ADO) only,
but in ado.net how to give i dont know
Below is the code for ado connection
db.Open DBcon_string
db.Execute ("SET SCHEMA=" & AppSchema)
db.Execute ("SET PATH=""SYSIBM"",""SYSFUN"",""SYSPROC"",""SYSIBMADM"",""" & AppSchema & """")

Note: db is adodb.connection
Replace AppSchema with ‘ETWRMS’

srinivasp


Responses

Posted by: Allemahesh on: 9/3/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can see the links below:-

http://stackoverflow.com/questions/153769/how-to-see-the-schema-of-a-db2-table-file
http://forums.pentaho.com/showthread.php?47314-Setting-DB-SCHEMA-name-when-using-DB2
https://forums.oracle.com/thread/2310251

Happy Coding.


Srinup97, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/3/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer the following link "Using an ADO.NET Entity Framework Data Provider"
http://www.datadirect.com/download/eval_docs/dotnet_win_quickstart.htm

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Srinup97, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/3/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi Srinu,
Look into the following connection strings.. There you can refer setting default schema
http://www.connectionstrings.com/ibm-db2/

http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.swg.im.dbclient.adonet.ref.doc%2Fdoc%2FDB2ConnectionClassConnectionStringProperty.html
http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.swg.im.dbclient.adonet.ref.doc%2Fdoc%2FDB2ConnectionStringBuilderClassSchemaListProperty.html

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Srinup97, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srinup97 on: 9/3/2013 [Member] Starter | Points: 25

Up
0
Down
iam connecting to the db2 database in this database different schemas are there.
I want to connect to connect particular schema only,
i tried that in connection string we cant give the schema,
After connection opening only we have to set the schema,
i have a code that i.e by using connect to the active data object(ADO) only,
but in ado.net how to give i dont know
Below is the code for ado connection
db.Open DBcon_string
db.Execute ("SET SCHEMA=" & AppSchema)
db.Execute ("SET PATH=""SYSIBM"",""SYSFUN"",""SYSPROC"",""SYSIBMADM"",""" & AppSchema & """")

Note: db is adodb.connection
Replace AppSchema with ‘ETWRMS’


Please tell me

srinivasp

Srinup97, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srinup97 on: 9/4/2013 [Member] Starter | Points: 25

Up
0
Down
Hi to everybody,
it is solved how to set schema in ado.net below is the code
OleDbConnection _connection = new OleDbConnection(strconnection);
OleDbCommand _cmd = new OleDbCommand();
_cmd.Connection = _connection;
_connection.Open();

string strRMSSchema = "SET SCHEMA= Schema name";
_cmd.CommandType = CommandType.Text;
_cmd.CommandText = strRMSSchema;
_cmd.ExecuteNonQuery();

string strpath = "SET PATH=SYSIBM,SYSFUN,SYSPROC,SYSIBMADM, Schema name
_cmd.CommandType = CommandType.Text;
_cmd.CommandText = strpath;
_cmd.ExecuteNonQuery();

string sql = "Spname";

_cmd.CommandType = CommandType.StoredProcedure;
_cmd.ExecuteNonQuery();

srinivasp

Srinup97, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response