aylin_sk

aylin_sk

  • NA
  • 87
  • 0

insertcmd

Dec 2 2004 5:22 AM
Hi, I created a web form including insert button..After I enter some values into the fields, I want them to be inserted into Oracle database..Is my script right??Or if I'm wrong in somewhere in my script, please inform me about it.. String insertCmd = "insert into PATIENTS (PATIENT_NUMBER," + " PATIENT_NAME, PATIENT_LASTNAME)" + " values (:patient_number, :patient_name, :patient_lastname)", myConnection); OracleCommand myCommand = new OracleCommand(insertCmd, myConnection); myCommand.Parameters.Add(new OracleParameter("patient_number", OracleType.Number, 5, "PATIENT_NUMBER")); myCommand.Parameters.Add(new OracleParameter("patient_name", OracleType.VarChar, 20,"PATIENT_NAME")); myCommand.Parameters.Add(new OracleParameter("patient_lastname", OracleType.VarChar, 20,"PATIENT_LASTNAME")); myCommand.Connection.Open(); myCommand.Connection.Close(); BindGrid(); public void BindGrid() { OracleConnection myConnection = new OracleConnection(myRegistry.getRegistryValue("connectionString")); OracleDataAdapter myCommand = new OracleDataAdapter("SELECT * FROM" + " PATIENTS", myConnection); DataSet myDataSet = new DataSet(); myCommand.Fill(myDataSet); dataGrid1.DataSource=myDataSet; dataGrid1.DataBind(); }

Answers (2)