473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with Oracle database

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));

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data.Odbc;
  3.  
  4. namespace MemberODBC{
  5. public enum MemberType {
  6. UnReg, Reg, Op,    Voice, Founder, Admin
  7. }
  8.  
  9. public class Member {
  10. private int sn = 0;
  11. private string nickName;
  12. private string password;
  13. private MemberType memberType;
  14. private string connection = "Driver={Microsoft ODBC for
  15. Oracle};Server=orcl;UID=scott;PWD=tiger";
  16.  
  17. public Member(string nickName)
  18. {
  19. this.nickName = nickName;
  20. memberType = MemberType.UnReg;
  21. }
  22.  
  23. public Member(string nickName, string password) : this (nickName) {
  24. this.password = password;
  25. memberType = MemberType.UnReg;
  26. }
  27.  
  28.  
  29. public void EnterPassword() {
  30. string pass = password;
  31.  
  32. try {
  33. string query = "SELECT * FROM member WHERE pass = '" + pass + "'";
  34. ReadData(query);
  35. if(pass == password) {
  36. memberType = MemberType.Reg;
  37. Console.WriteLine("The password is accepted");
  38. }
  39. else {
  40. Console.WriteLine("The password is not accepted");
  41. }
  42. }
  43. catch {
  44. Console.WriteLine("EnterPassword() FAILED");
  45. }
  46. }
  47.  
  48. public void ReadData(string query) {
  49. OdbcConnection dbConn = new OdbcConnection(connection);
  50. dbConn.Open();
  51.  
  52. try {
  53. string sqlString = query;
  54. OdbcCommand sqlCommand = new OdbcCommand(sqlString, dbConn);
  55. OdbcDataReader reader = sqlCommand.ExecuteReader();
  56. while(reader.Read()) {
  57. sn = reader.GetInt32(0);
  58. nickName = reader.GetString(1);
  59. password = reader.GetString(2);
  60. }
  61. reader.Close();
  62. dbConn.Close();
  63.  
  64. }
  65. catch {
  66. Console.WriteLine("Member:\tConnection did not succeeed");
  67. }
  68. }
  69.  
  70.  
  71. public static void Main() {
  72. Member m = new Member("X", "X");
  73. m.EnterPassword();
  74. Console.ReadLine();
  75. }
  76. }
  77. }
  78.  
Nov 16 '05 #1
3 1445
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

"Thubaiti" wrote:
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));

Expand|Select|Wrap|Line Numbers
  1.  using System;
  2.  using System.Data.Odbc;
  3.  namespace MemberODBC{
  4.      public enum MemberType {
  5.          UnReg, Reg, Op,    Voice, Founder, Admin
  6.      }
  7.      public class Member {
  8.          private int sn = 0;
  9.          private string nickName;
  10.          private string password;
  11.          private MemberType memberType;
  12.          private string connection = "Driver={Microsoft ODBC for
  13.  Oracle};Server=orcl;UID=scott;PWD=tiger";
  14.          public Member(string nickName)
  15.          {
  16.              this.nickName = nickName;
  17.              memberType = MemberType.UnReg;
  18.          }
  19.          public Member(string nickName, string password) : this (nickName) {
  20.              this.password = password;
  21.              memberType = MemberType.UnReg;
  22.          }
  23.          public void EnterPassword() {
  24.              string pass = password;
  25.              try {
  26.                  string query = "SELECT * FROM member WHERE pass = '" + pass + "'";
  27.                  ReadData(query);
  28.                  if(pass == password) {
  29.                      memberType = MemberType.Reg;
  30.                      Console.WriteLine("The password is accepted");
  31.                  }
  32.                  else {
  33.                      Console.WriteLine("The password is not accepted");
  34.                  }
  35.              }
  36.              catch {
  37.                  Console.WriteLine("EnterPassword() FAILED");
  38.              }
  39.          }
  40.          public void ReadData(string query) {
  41.              OdbcConnection dbConn = new OdbcConnection(connection);
  42.              dbConn.Open();
  43.              try {
  44.                  string sqlString = query;
  45.                  OdbcCommand sqlCommand = new OdbcCommand(sqlString, dbConn);
  46.                  OdbcDataReader reader = sqlCommand.ExecuteReader();
  47.                  while(reader.Read()) {
  48.                      sn = reader.GetInt32(0);
  49.                      nickName = reader.GetString(1);
  50.                      password = reader.GetString(2);
  51.                  }
  52.                  reader.Close();
  53.                  dbConn.Close();
  54.              }
  55.              catch {
  56.                  Console.WriteLine("Member:\tConnection did not succeeed");
  57.              }
  58.          }
  59.          public static void Main() {
  60.              Member m = new Member("X", "X");
  61.              m.EnterPassword();
  62.              Console.ReadLine();
  63.          }
  64.      }
  65.  }
  66.  

Nov 16 '05 #2
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");
}
}
}
}
-----

"Guest" wrote:
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

Nov 16 '05 #3
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
make sure that the compiler that you are executing >corresponds to version 1.1 on themachine


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: A. Fuentes | last post by:
Fellow Oracle Netters: I have the following problem: Enviroment: Oracle9i/AIX5.2/Veritas vxvm I am trying to create an Oracle database using RAW devices UNDER the Veritas vxvm.(Veritas...
1
by: Cherrish Vaidiyan | last post by:
sir, I have a small error in Listener configuration.I have two system with a database in each. I am using Red Hat 9 and Oracle 9i. so i shall anme the database and system. system 1 - node2 ...
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
0
by: A. Fuentes | last post by:
Fellow Oracle Netters: I have the following problem: Enviroment: Oracle9i/AIX5.2/Veritas vxvm I am trying to create an Oracle database using RAW devices UNDER the Veritas vxvm.(Veritas...
0
by: darryldejesus | last post by:
Do you know how to set up a memory allocation for each database only not entirely for all the databases in a server using MS SQL? the plan is to configure a database to consume up to 500 mb (cache)...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.