Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7991509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:18:39+00:00 2026-06-04T13:18:39+00:00

I am trying to specify the default schema/instance as part of a connection string

  • 0

I am trying to specify the default schema/instance as part of a connection string (or specific command) so it does not need to be part of the query.

OdbcConnection conn = new OdbcConnection("Driver={IBM DB2 ODBC DRIVER}; Database=myDB; Hostname=myHostName; Port=myPort; Protocol=TCPIP; Uid=myID; Pwd=myPW;");
OdbcCommand comm = new OdbcCommand("select count(*) from customers", conn);
conn.Open();
var value = comm.ExecuteScalar();
conn.Close();

Unfortunately this fails with the error:

ERROR [42S02] [IBM][CLI Driver][DB2] SQL0204N myID.customers is an undefined name. SQLSTATE=42704.

Notice it’s using myID where the Schema/Instance should be. If I specify the schema/instance explicity:

OdbcCommand comm = new OdbcCommand("select count(*) from mySCHEMA.customers", conn);

it works as expected. I’d like to specify mySCHEMA as part of the Connection String, similar to “Initial Catalog” when using MS SQL Server.

After a bunch of experimentation and googling, I can’t seem to figure it out. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:18:40+00:00Added an answer on June 4, 2026 at 1:18 pm

    Wow, this one was obvious. I just need CurrentSchema=mySCHEMA in the connection string.

    For some reason I didn’t connect that dot right away after working through http://www.connectionstrings.com/ibm-db2 (tried all sorts of variations like Schema, Default Schema, etc). Hopefully this helps someone in the future…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some XML schema code to specify that a particular
I am currently trying to specify custom error messages in grails for the default
I`m trying to query all task lists. I have modified default Task content type
I am trying to specify an alternative jre (my default is 1.6 and i
I'm trying to specify a relative directory in the web.xml file. I basically want
im trying out paypals html api where you specify price, item_name, customer information and
I'm trying to modify the Bootstrap collapse plugin to allow me to specify whether
I am trying to put together an index using terms, which I specify as
Trying to comply with StackOverflow's suggestion of asking a question, not creating a discussion,
THIS QUESTION IS NOT ABOUT HOW TO SET DEFAULT VALUE OF A WIDGET Hello

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.