how to connect my oracleconnection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • honeygracee
    New Member
    • Feb 2007
    • 2

    how to connect my oracleconnection

    hi i am doing a program and i need to connect 5 projects in 1 solution but right now i am only doing the first project to be connected to the oracle connnection.

    can you help me on how can i view the first name, middle name and last time on my textbox if i search the employee number ?
    below is my code sample..
    please help me..

    Code:
            Try
                Dim strempno As String
                Dim rs As OracleAccess.clsOracleConnection
                strempno = txtEmpno.Text
                If strempno = "" Or strempno = " " Then
                    MessageBox.Show("EmployeeNo is always necessary", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Call LSubfrmCnlenabled(False)
                    rs.PFstrsConnect = True
    
                    txtEmpno.Text = "select EMPLOYEE_NO from M_EMPLOYEE;"
                    txtFname.Text = "select FIRST_NAME from M_EMPLOYEE;"
    
                End If
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error on btnOK", MessageBoxButtons.OK, MessageBoxIcon.Error)
    
            End Try
    Last edited by kenobewan; Feb 21 '07, 12:53 PM. Reason: Add code tags
  • kuzen
    New Member
    • Dec 2006
    • 20

    #2
    Hi
    First of all empty field checking is a user machine process. You could use javascript, you can write it yourself or simply use visual required field validator for that.If there is an empty field, your application should never refer to the database.
    For this, check the page validity in the beginning of your button_click event:
    Code:
    If not Page.Isvalid then
    return
    else
    ....
    end if
    About connection:

    Import System.Data.Ora cleClient first.
    dim yourconn as new OracleConnectio n
    yourconn.connec tionstring = "user id=...; data source=yourserv er; password=..."
    yourconn.open
    dim yourcomm as new Oraclecommand
    yourcomm.connec tion=yourconn
    yourcomm.comman dtype=commandty pe.text
    yourcomm.comman dtext="your SQL query"
    ...
    I hope I did not misunderstand you and this helps
    Regards

    Comment

    • honeygracee
      New Member
      • Feb 2007
      • 2

      #3
      Try
      Dim strempno As String
      Dim rs As OracleAccess.cl sOracleConnecti on
      Dim command As SqlCommand
      Dim reader As SqlDataReader = command.Execute Reader
      strempno = txtEmpno.Text
      Dim myconnection As SqlConnection
      If strempno = "" Or strempno = " " Then
      MessageBox.Show ("EmployeeNo is always necessary", "Error", MessageBoxButto ns.OK, MessageBoxIcon. Error)
      Call LSubfrmCnlenabl ed(False)
      myconnection.Co nnectionString = ("userId = username;" + "password = password;" + "datasource = Tasdi;")
      myconnection.Op en()
      command.Connect ion = myconnection
      command.Command Type = CommandType.Tex t
      command.Command Text = ("select * from M_EMPLOYEE;")


      If reader.HasRows Then

      End If

      End If

      Catch ex As Exception
      MessageBox.Show (ex.Message, "Error on btnOK", MessageBoxButto ns.OK, MessageBoxIcon. Error)

      End Try

      thank you for the help now what i did is at the above code..i don't know if i did it right my table name is M_EMPLOYEE and the fields are first name,, middle name and last name there are also birthday etc.. now this button is for the ok button because if i'm going to write an employee no. on the textbox(employe eno.) and i click on the button ok the the existing employee will view the following fields on the txtbox firstname, txtboxmiddlenam e, txtboxlastname and etc..I already inputed the "if read.hasrows for the starting to get the list from my sql but i'm not sure if im right...

      Comment

      Working...