aylin_sk

aylin_sk

  • NA
  • 87
  • 0

insertcmd in Oracle

Dec 2 2004 7:11 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.. I got lots of errors :(( private void OnButton_Click(object sender, System.EventArgs e) { OracleConnection myConnection = new OracleConnection(myRegistry.getRegistryValue("connectionString")); myConnection.Open (); String insertCmd = "nsert 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("patient_number", OracleType.Number, 5, "PATIENT_NUMBER"); myCommand.Parameters.Add("patient_name", OracleType.VarChar, 20,"PATIENT_NAME"); myCommand.Parameters.Add("patient_lastname", OracleType.VarChar, 20,"PATIENT_LASTNAME"); myCommand.ExecuteNonQuery(); BindGrid(myConnection); myConnection.Close (); } public void BindGrid() { OracleDataAdapter myCommand = new OracleDataAdapter("SELECT * FROM PATIENTS", myConnection); DataSet myDataSet = new DataSet(); myCommand.Fill(myDataSet); dataGrid1.DataSource=myDataSet; dataGrid1.DataBind(); }

Answers (2)