Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. INSERT problem wiht a web form

INSERT problem wiht a web form

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-netsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beacon dartmouth
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups