tushar tayal

tushar tayal

  • NA
  • 1
  • 8.2k

how to check the textbox value

Sep 27 2010 6:23 AM
 pleaase tell me how to use the stored procedure in C#.NET

I am making a windowform in which i aminserted the data into the database.
In database one of my fiels is unique and cannot insert the duplicate value. please tell me how to check the value in textbox to the database.

my code is
DatabaseInfo database = new DatabaseInfo();
                   database.DatabaseName = "ALPHA";
                   database.ServerDsn = "DELLVOSTRO";
                   database.DbType = DatabaseType.Microsoft;

                   AlphaDatabaseManager alphadatabasemanager = new AlphaDatabaseManager(database);
                   SqlConnection conn = new SqlConnection("Data Source = DELLVOSTRO; Initial Catalog = ALPHA; Integrated Security = True");
                   DataSet localDataSet1 = new DataSet();



                   string sTable = "Insert Into COUNTRY (UNIQUEID , ISO_CODE , ALPHA_CODE , NUMERIC_CODE , NAME , CONTINENT) values('"
                       + ultraNumericEditorUniqueID.Text + "','" + ultraMaskedEditIsoCode.Text + "','" + ultraMaskedEditAlphaCode.Text + "','"
                       + ultraNumericEditorNumericCode.Text + "','" + ultraMaskedEditName.Text + "','" + ultraComboEditorContinent.SelectedItem.DataValue + "')";
                   SqlTransaction transation;
                   try
                   {
                       alphadatabasemanager.OpenConnection(conn);
                       transation = conn.BeginTransaction();
                       alphadatabasemanager.ExecuteNonQueryCommand(sTable, conn, transation);
                       alphadatabasemanager.CommitTransaction(transation);

                   }

                   catch (Exception ex)
                   {
                       MessageBox.Show(ex.Message);
                   }
                   alphadatabasemanager.CloseConnection(conn);
                   MessageBox.Show("Data has been sucessfully inserted");
               }

          

Answers (1)