Problem with Oracle database

G

Guest

hi there..

I have a problem with this code...

any help please ?

SQL: CREATE TABLE member (sn NUMBER(6), nickname VARCHAR2(30), password
VARCHAR2(30));

Code:
using System;
using System.Data.Odbc;

namespace MemberODBC{
public enum MemberType {
UnReg, Reg, Op,	Voice, Founder, Admin
}

public class Member {
private int sn = 0;
private string nickName;
private string password;
private MemberType memberType;
private string connection = "Driver={Microsoft ODBC for
Oracle};Server=orcl;UID=scott;PWD=tiger";

public Member(string nickName)
{
this.nickName = nickName;
memberType = MemberType.UnReg;
}

public Member(string nickName, string password) : this (nickName) {
this.password = password;
memberType = MemberType.UnReg;
}


public void EnterPassword() {
string pass = password;

try {
string query = "SELECT * FROM member WHERE pass = '" + pass + "'";
ReadData(query);
if(pass == password) {
memberType = MemberType.Reg;
Console.WriteLine("The password is accepted");
}
else {
Console.WriteLine("The password is not accepted");
}
}
catch {
Console.WriteLine("EnterPassword() FAILED");
}
}

public void ReadData(string query) {
OdbcConnection dbConn = new OdbcConnection(connection);
dbConn.Open();

try {
string sqlString = query;
OdbcCommand sqlCommand = new OdbcCommand(sqlString, dbConn);
OdbcDataReader reader = sqlCommand.ExecuteReader();
while(reader.Read()) {
sn = reader.GetInt32(0);
nickName = reader.GetString(1);
password = reader.GetString(2);
}
reader.Close();
dbConn.Close();

}
catch {
Console.WriteLine("Member:\tConnection did not succeeed");
}
}


public static void Main() {
Member m = new Member("X", "X");
m.EnterPassword();
Console.ReadLine();
}
}
}
 
G

Guest

Hi,
Any particular error that you are getting? provide me if you have one.
Couple of things I observed are as below:
1. Make sure you have Oracle client and networking components installed on
the machine running this code. You will not be able to use Oracle driver
otherwise. I got an error message when I executed this piece of code
2. Reference to System.Data.ODBC is new in Framework 1.1, did you make sure
that the compiler that you are executing corresponds to version 1.1 on the
machine?

HTH
Guest
 
G

Guest

Hi,

1. Oracle10g installed in my machine, I do not know any thing about Oracle
client and networking components
2. I am using 1.1

this code I tested, but i had a problem like the previews problem

the error is:
An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in
system.data.dll

Additional information: System error.
----

my code:
using System;
using System.Data.Odbc;

namespace ConsoleApplication1 {
public class Member {
public static void Main() {
string sqlString = "SELECT empno FROM member";
OdbcConnection dbConn = new OdbcConnection("Driver={Microsoft ODBC for
Oracle};Server=orcl;UID=scott;PWD=tiger");
dbConn.Open();

try {
OdbcCommand sqlCommand = new OdbcCommand(sqlString, dbConn);
OdbcDataReader reader = sqlCommand.ExecuteReader();
while(reader.Read()) {
Console.WriteLine(reader.GetInt32(0));
}
reader.Close();
dbConn.Close();

}
catch {
Console.WriteLine("Member:\tConnection did not succeeed");
}
}
}
}
 
L

Ling.xu

Hi, Could you please show me how to use .Net Framework version 1.1
compiler from the command/dos prompt? When I type "vbc /t:library...",
it automatically using the old version 1.0.

Many thnaks,

LX
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top