Forum Stats

  • 3,783,408 Users
  • 2,254,768 Discussions
  • 7,880,383 Comments

Discussions

oracle connection problem...

user13328581
user13328581 Member Posts: 1,327 Silver Badge
edited Dec 13, 2011 5:22PM in .NET Stored Procedures
dear all;

I have the following syntax below
 protected void Button1_Click(object sender, EventArgs e)
    {

 string oradb = "User Id=finance;Password=finace1;Data Source=XE";
        string sql = "select ID, Create_date from t_mobile";
        OracleDataAdapter adapter = new OracleDataAdapter(oradb, sql);
        OracleCommandBuilder builder = new OracleCommandBuilder(adapter);

        DataSet dataset = new DataSet();

        adapter.Fill(dataset, "t_mobile");

        DataTable mytable = dataset.Tables["t_mobile"];

        GridView1.DataSource = mytable;
        GridView1.DataBind();
    }
but I keep getting the error message connection not well formatted, how I do connect to my sql*plus using visual web developer 2010 express for practicing purposes. thank you. a simple code example will also help
«1

Answers

  • 890764
    890764 Member Posts: 48
    edited Dec 13, 2011 5:22PM
    Here are a couple of connection string used to connect to Oracle. http://www.connectionstrings.com/oracle See if this will solve your problem. I think the first one will work for you.

    *[url http://www.java-forums.org/blogs/advanced-java/collection/]Java collection*
  • user13328581
    user13328581 Member Posts: 1,327 Silver Badge
    that didnt work...
  • user13328581
    user13328581 Member Posts: 1,327 Silver Badge
    edited Oct 5, 2011 9:00PM
    OK i am a little progress, now the only error is connection is not open unfortunately
      DataTable emptable = new DataTable();
            string oradb = "Data Source = (DESCRIPTION ="
        + "(ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = olisa-VAIO)(PORT = 1521)))"
        + "(CONNECT_DATA= (SERVER = DEDICATED)(SERVICE_NAME = XE)));"
        + "User Id = finance; Password=financecc;";
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            string sql = "select ID, Create_date from t_mobile";
            OracleCommand cmd = new OracleCommand(sql, conn);
            cmd.CommandType = CommandType.Text;
            emptable.Load(cmd.ExecuteReader());
            GridView1.DataSource = emptable;
            GridView1.DataBind();
    
            conn.Close();
            conn.Dispose();
    Edited by: user13328581 on Oct 5, 2011 5:59 PM
  • 890764
    890764 Member Posts: 48
    Can you please provide the error log? Thanks.
  • user13328581
    user13328581 Member Posts: 1,327 Silver Badge
    i get the following error, ORA-6413: Connection not open.
  • 890764
    890764 Member Posts: 48
    Are you sure all the Parameters are OK?
    To make sure of that, if you use SQL Developer, right click on your connection (assuming you have one that works), then select TNS as Connection Type, then click Connection Identifier to enable the text-field, and copy the connection string from there.

    PS: Make sure there is no firewall that might block your connection, or the database accepts remote connections.
  • user13328581
    user13328581 Member Posts: 1,327 Silver Badge
    i am using sql plus unfortunately, how do you apply such a check in sql plus
  • 890764
    890764 Member Posts: 48
    I really don't know that, as I worked with it just a little, but use the same settings as you used when you set it up, or ask the one who did if it weren't you. Or there is anyone else here who knows how to do it. :)
  • user13328581
    user13328581 Member Posts: 1,327 Silver Badge
    I use pl/sql developer at work and my connections works fine there but i am trying to use a free sql tool which is sql*plus and things arent just working and i am trying to figure out why
  • 890764
    890764 Member Posts: 48
    Can you post the connection settings from you sql developer? (nothing confidential - you can mask the user/pass/host) as I need to see what type it is.
This discussion has been closed.