Click here to Skip to main content
15,912,756 members
Home / Discussions / Database
   

Database

 
AnswerRe: C# winform -> SQL server Trouble writing null values Pin
i.j.russell20-Mar-10 12:19
i.j.russell20-Mar-10 12:19 
GeneralRe: C# winform -> SQL server Trouble writing null values Pin
Mattzimmerer20-Mar-10 12:44
Mattzimmerer20-Mar-10 12:44 
Questionoracle & .net Pin
amer shammout20-Mar-10 4:17
amer shammout20-Mar-10 4:17 
QuestionRe: oracle & .net Pin
i.j.russell20-Mar-10 8:51
i.j.russell20-Mar-10 8:51 
GeneralRe: oracle & .net Pin
amer shammout20-Mar-10 21:24
amer shammout20-Mar-10 21:24 
AnswerRe: oracle & .net Pin
Don Burton21-Mar-10 10:31
Don Burton21-Mar-10 10:31 
GeneralRe: oracle & .net Pin
amer shammout21-Mar-10 21:42
amer shammout21-Mar-10 21:42 
AnswerRe: oracle & .net Pin
Аslam Iqbal26-Mar-10 10:38
professionalАslam Iqbal26-Mar-10 10:38 
You have to use Package insted of procedure.

Search in oracle or MSDN to get help about package.
here is an example of package (Collected from MSDN):

Drop table Emp;
drop table DEPT;
CREATE TABLE DEPT
   (DEPTNO NUMBER(2,0) NOT NULL, 
   DNAME VARCHAR2(14) NULL, 
   LOC VARCHAR2(13) NULL,
   PRIMARY KEY (DEPTNO)
   );

   INSERT INTO Dept VALUES(11,'Sales','Texas');
   INSERT INTO Dept VALUES(22,'Accounting','Washington');
   INSERT INTO Dept VALUES(33,'Finance','Maine');

   CREATE TABLE EMP
   (EMPNO NUMBER(4,0) NOT NULL, 
   ENAME VARCHAR2(10) NULL, 
   JOB VARCHAR2(9) NULL, 
   MGR NUMBER(4,0) NULL,
   HIREDATE DATE NULL,
   SAL NUMBER(7,2) NULL, 
   COMM NUMBER(7,2) NULL, 
   DEPTNO NUMBER(2,0) NULL,
   FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO),  
   PRIMARY KEY (EMPNO)
   ); 

   INSERT INTO Emp VALUES(123,'Bob','Sales',555,'28-JAN-79',35000,12,33);
   INSERT INTO Emp VALUES(321,'Sue','Finance',555,'12-MAY-83',42000,12,11);
   INSERT INTO Emp VALUES(234,'Mary','Account',555,'14-AUG-82',33000,12,22);

CREATE OR REPLACE PACKAGE curspkg_join AS 
        TYPE t_cursor IS REF CURSOR ; 
        Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor); 
   END curspkg_join;
/

CREATE OR REPLACE PACKAGE BODY curspkg_join AS
   Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor) 
   IS 
        v_cursor t_cursor; 
   BEGIN 
        IF n_EMPNO <> 0 
        THEN
             OPEN v_cursor FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO 
                  AND EMP.EMPNO = n_EMPNO;

        ELSE 
             OPEN v_cursor FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO;

        END IF;
        io_cursor := v_cursor; 
   END open_join_cursor1; 
   END curspkg_join;


Convert the following VB Code into C# to execute that package:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Exception
        Dim Ds As New DataSet()
        Dim Oraclecon As New OracleConnection("Server=giit;Uid=scott;Pwd=tiger")

        Oraclecon.Open()


        Dim myCMD As New OracleCommand()
        myCMD.Connection = Oraclecon
        myCMD.CommandText = "curspkg_join.open_join_cursor1"
        myCMD.CommandType = CommandType.StoredProcedure
        myCMD.Parameters.Add(New OracleParameter("n_empno", OracleType.Number)).Value = TextBox1.Text
        myCMD.Parameters.Add(New OracleParameter("io_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output

'MyDA is your dataadapter
        Dim MyDA As New OracleDataAdapter(myCMD)

        Try

            MyDA.Fill(Ds)
        Catch x
            MessageBox.Show(x.Message.ToString)
        End Try



        DataGrid1.DataSource = Ds.Tables(0)
        Ds.WriteXml("C:\packqry.xml")
        Oraclecon.Close()
    End Sub

GeneralRe: oracle & .net Pin
amer shammout28-Mar-10 2:03
amer shammout28-Mar-10 2:03 
QuestionPermissions Problem? [SOLVED] Pin
#realJSOP20-Mar-10 3:31
professional#realJSOP20-Mar-10 3:31 
AnswerRe: Permissions Problem? Pin
Luc Pattyn20-Mar-10 3:38
sitebuilderLuc Pattyn20-Mar-10 3:38 
GeneralRe: Permissions Problem? Pin
#realJSOP20-Mar-10 3:40
professional#realJSOP20-Mar-10 3:40 
GeneralRe: Permissions Problem? Pin
Luc Pattyn20-Mar-10 3:53
sitebuilderLuc Pattyn20-Mar-10 3:53 
GeneralRe: Permissions Problem? Pin
#realJSOP20-Mar-10 3:50
professional#realJSOP20-Mar-10 3:50 
QuestionRetrieving the lastest instance of a record [ SOLVED] Pin
#realJSOP20-Mar-10 2:53
professional#realJSOP20-Mar-10 2:53 
AnswerRe: Retrieving the lastest instance of a record Pin
Luc Pattyn20-Mar-10 3:17
sitebuilderLuc Pattyn20-Mar-10 3:17 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP20-Mar-10 3:32
professional#realJSOP20-Mar-10 3:32 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP20-Mar-10 4:15
professional#realJSOP20-Mar-10 4:15 
GeneralRe: Retrieving the lastest instance of a record Pin
Luc Pattyn20-Mar-10 4:23
sitebuilderLuc Pattyn20-Mar-10 4:23 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP20-Mar-10 5:02
professional#realJSOP20-Mar-10 5:02 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell20-Mar-10 8:48
i.j.russell20-Mar-10 8:48 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 2:01
professional#realJSOP21-Mar-10 2:01 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell21-Mar-10 2:32
i.j.russell21-Mar-10 2:32 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 10:41
professional#realJSOP21-Mar-10 10:41 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell21-Mar-10 11:28
i.j.russell21-Mar-10 11:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.