INSERT problem wiht a web form
-
The form uses data from an existing record and allows to create a new one with some of the existing data. Obviously, no two records can be identical, so there's a constraint on the table that spans three columns (Logical_Name, Physical_Name, and Table_ID) preventing identical values in those three columns to be used on a new record. This works just fine SQL-wise at a prompt, because I can do inserts directly on the DB server but the aspx page appears not to be reading the modified values in the text boxes, and instead keeps sending the original values, effectively throwing a constraint violation error every time. This is the first time I'm doing this type of form in ASP.NET, so here's the code for the insert Sub:
Sub subBtnClick( s As Object, e As EventArgs ) Dim strInsert, radReq As String Dim cmdInsert As SqlCommand If radYes.checked radReq = "Yes" Else radReq = "No" End If conMeta = New SqlConnection( "Server='DOHSDBS96';trusted_connection=true;Database='METADATAv2'" ) strInsert = "INSERT INTO A_T_Field (Logical_Name,Physical_Name,[Description],Edit_Mask,atfSize,atfDecimal," & _ "atfDomain,Business_Rule,Required,Default_Value,Table_ID,Data_Type_ID,Quality_ID,Status_ID)" & _ "VALUES (@lName,@pName,@desc,@eMask,@size,@dcml,@domn,@bRule,@req,@dValue,@tblID,@dtID,@qualID,@statID)" 'cmdInsert = New SqlCommand( "sTblAddNew", conMeta ) 'cmdInsert.CommandType = CommandType.StoredProcedure cmdInsert = New SqlCommand( strInsert, conMeta ) cmdInsert.Parameters.Add( "@lName", txtLogiName.Text ) cmdInsert.Parameters.Add( "@pName", txtPhysName.Text ) cmdInsert.Parameters.Add( "@desc", txtDesc.Text ) cmdInsert.Parameters.Add( "@eMask", txtEditMask.Text ) cmdInsert.Parameters.Add( "@size", txtSize.Text ) cmdInsert.Parameters.Add( "@dcml", txtDecimal.Text ) cmdInsert.Parameters.Add( "@domn", txtDomain.Text ) cmdInsert.Parameters.Add( "@bRule", txtBusRule.Text ) cmdInsert.Parameters.Add( "@req", radReq ) cmdInsert.Parameters.Add( "@dValue", txtDefValue.Text ) cmdInsert.Parameters.Add( "@tblID", txtTblID.Text ) cmdInsert.Parameters.Add( "@dtID", ddlDataType.SelectedItem.Value ) cmdInsert.Parameters.Add( "@qualID", ddlQualities.SelectedItem.Value ) cmdInsert.Parameters.Add( "@statID", ddlStatus.SelectedItem.Value ) Try c