olybobo 0 Newbie Poster

This is the solution below

I finally got it working all...here is the simple solutions. First and foremorst, make sure you are using the right various of sql*plus because I noticed for visual studio 2010 express, it is only compatible with Oracle Database Express Edition 11g Release 2, don't know why but I tired oracle 10g and that didnt work. Oracle Database Express Edition 11g Release 2 can be found at the following link below.

http://www.oracle.com/technetwork/database/express-edition/downloads/index.html

the next step is to download the right drivers to establish the connection which can found at the following link below

http://www.oracle.com/technetwork/developer-tools/visual-studio/downloads/index.html and the name of the driver is ODAC 11.2 Release 3 (11.2.0.2.1) with Oracle Developer Tools for Visual Studio. That is the right driver for oracle 11g for asp.net 4.0.

Once the driver has been downloaded, it is time to write a simple program. An example is shown below

protected void Button1_Click(object sender, EventArgs e)
{
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();


}

notice that you will need the right oracle .dll to establish the connection, this can be done by adding a reference, in the reference section click on browser and navigate to the following directory to add the oracle.dataaccess.dll. the …

olybobo 0 Newbie Poster

hello!
if i look to your code i don't see anything wrong,so what i want to do is that i will give you a simple code that work 100%,so test it with VS 2010 and you will know from where the problem.
i want to help you ,but VS 2005 isn't installed write now in my laptop,but try this code and tell me if it worked or not:
first create this table in the oracle database:

create table test(FirstName varchar2(50))

the create a new asp.net website with VS 2010 or new empty website then add a new aspx webform and in the code behind add this code:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String con = "DRIVER={Microsoft ODBC for Oracle};DSN=XE;UID=user;PWD=pass;SERVER=localhost;";
        OdbcConnection conx = new OdbcConnection(con);
        conx.Open();
        OdbcCommand command = new OdbcCommand("insert into test values('hello')", conx);
        command.ExecuteNonQuery();

        conx.Close();

       
    }
}

so it will work in VS 2005 and in VS 2010 in a 32 bits machine.
and it's for you to try it and you will certainly know where is the problem.
Regards!

I am getting the following error below

ERROR [NA000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-06413: Connection not open.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).

olybobo 0 Newbie Poster

hello!
if you have VS 2005 so try the same code with it,it should work if you connection string is correct because i didn't check your code or your connection string.
so if in VS 2005 work so don't wast your time for trying to connect to an oracle database from VS 2010 in a 64 bits machine,because i had this problem and i spend over a week to solve it with no success,and i could say it the VS 2010 problem(maybe only in my laptop).

so just try using VS 2005,maybe it would save your time.
Regards!

i do not have vs 2005 unfortunately, can you please look at my code and verify or test it on a vs 2005 machine since you have one and let me know

olybobo 0 Newbie Poster

this is the modified code below except that i am getting the error message connection not open unfortunately...i am trying to connect to my sql*plus all

protected void Button1_Click(object sender, EventArgs e)
    {

        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 = scott; Password=tiger;";
        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();

    }
olybobo 0 Newbie Poster

Dear all;


I have googled everywhere but still cant find a good robust code for this. I would like to use an XML to create a menu and submenu in asp.net in the master page. This is the design I would like

About Me|Interest

now if About Me is clicked on it shows all its associated submenu, so this is what you get

About Me|Interest

City|Place|Age

if Interest is clicked on instead, this is what you get instead,

About Me|Interest

Hobby|Games

How do you implement all this in asp.net, all help is greatly appreciated. Thank you. A good sample code will really help.

olybobo 0 Newbie Poster

dear all I have the following sample code which i am trying to use to connect to sql*plus in visual studio 2010 but i keep getting the error message connection string is not well-formed. see my code below

protected void Button1_Click(object sender, EventArgs e)
    {

        string oradb = "User Id=finance;Password=finacecc;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();


    }
olybobo 0 Newbie Poster

Ok, that fix the illegal error problem, however though the code is currently not doing much unfortunately, it doesnt show the associated submenu when the main menu is clicked on unfortunately.

olybobo 0 Newbie Poster

Dear all;

I have the following code below and I have been spending time trying to debug it but I can't understand why I am getting the illegal character error message. See my code below. Thank you.

workheader.master.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Xml;

public partial class workheader : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        load();
    }

    protected void load()
    {
        
       
       XDocument doc = XDocument.Load(Server.MapPath("App_Data/XMLFile.xml"));

        foreach (XElement menuItem in doc.Elements("MainMenu").Elements("MenuItem"))
        {
            string a = menuItem.Element("LinkURL").Value;
            string b = menuItem.Element("LinkLabel").Value;


            hp.Text = b;
            hp.NavigateUrl = a;

            if (doc.Elements("submenu") != null)
            {
                foreach (XElement subItem in doc.Elements("MainMenu").Elements("MenuItem").Elements("SubMenu").Elements("SubMenuItem"))
                {
                    string c = subItem.Element("LinkURL").Value;
                }
            }

        }


    }

}

workheader.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="workheader.master.cs" Inherits="workheader" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">

    <asp:HyperLink ID="hp" runat="server" />

    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

XML code

<?xml version="1.0" encoding="utf-8" ?>
<MainMenu>
	<MenuItem>
		<LinkLabel>Begin</LinkLabel>
		<LinkURL>DefaultA.aspx</LinkURL>
	</MenuItem>
	<MenuItem>
		<LinkLabel>
			Default B
		</LinkLabel>
		<LinkURL>
			DefaultB.aspx
		</LinkURL>
	</MenuItem>

	<MenuItem>
		<LinkLabel>
			Default reports
		</LinkLabel>
		<LinkURL>
			DefaultC.aspx
		</LinkURL>
		<SubMenu>
			<SubMenuItem>
				<LinkLabel>
					Default C established
				</LinkLabel>
				<LinkURL>
					DefaultC.aspx
				</LinkURL>
			</SubMenuItem>

			<SubMenuItem>
				<LinkLabel>
					Default D
				</LinkLabel>
				<LinkURL>
					DefaultD.aspx
				</LinkURL>
			</SubMenuItem>

			<SubMenuItem>
				<LinkLabel>
					Default E
				</LinkLabel>
				<LinkURL>
					DefaultE.aspx
				</LinkURL>
			</SubMenuItem>
			
			
		</SubMenu>
	</MenuItem>
</MainMenu>

All help is appreciated. Thank you.