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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Newbie Help

Newbie Help

Scheduled Pinned Locked Moved ASP.NET
helpdatabasesysadminquestion
4 Posts 2 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.
  • K Offline
    K Offline
    kruegersck
    wrote on last edited by
    #1

    All - I am trying to create a simple app that will capture emails and when my users try to remove their email from the db they get an error. Here is my ASP code: <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/mail.mdb" DeleteCommand="DELETE FROM [Email] WHERE (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))" InsertCommand="INSERT INTO [Email] ([Email]) VALUES (?)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Email] FROM [Email]"> <DeleteParameters> <asp:ControlParameter ControlID="txtEmail" Name="original_Email" PropertyName="Text" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="Email" Type="String" /> </InsertParameters> </asp:AccessDataSource> Here is the code below: protected void btnSubscribe_Click(object sender, EventArgs e) { AccessDataSource1.InsertParameters["Email"].DefaultValue = txtEmail.Text; try { AccessDataSource1.Insert(); txtEmail.Text = ""; lblError.Text = "Email sucessfully added"; } catch { lblError.Text = "Email already exists"; } } protected void btnUnSub_Click(object sender, EventArgs e) { AccessDataSource1.DeleteParameters["Email"].DefaultValue = txtEmail.Text; try { AccessDataSource1.Delete(); txtEmail.Text = ""; lblError.Text = "Email has been removed"; } catch { lblError.Text = "Email doesn't exist"; } } Thanks for all your help

    V 1 Reply Last reply
    0
    • K kruegersck

      All - I am trying to create a simple app that will capture emails and when my users try to remove their email from the db they get an error. Here is my ASP code: <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/mail.mdb" DeleteCommand="DELETE FROM [Email] WHERE (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))" InsertCommand="INSERT INTO [Email] ([Email]) VALUES (?)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Email] FROM [Email]"> <DeleteParameters> <asp:ControlParameter ControlID="txtEmail" Name="original_Email" PropertyName="Text" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="Email" Type="String" /> </InsertParameters> </asp:AccessDataSource> Here is the code below: protected void btnSubscribe_Click(object sender, EventArgs e) { AccessDataSource1.InsertParameters["Email"].DefaultValue = txtEmail.Text; try { AccessDataSource1.Insert(); txtEmail.Text = ""; lblError.Text = "Email sucessfully added"; } catch { lblError.Text = "Email already exists"; } } protected void btnUnSub_Click(object sender, EventArgs e) { AccessDataSource1.DeleteParameters["Email"].DefaultValue = txtEmail.Text; try { AccessDataSource1.Delete(); txtEmail.Text = ""; lblError.Text = "Email has been removed"; } catch { lblError.Text = "Email doesn't exist"; } } Thanks for all your help

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      When you post in CodepProject use the Pre tags, there is a Tool bar for you. This will make us keen to help you. Formating in important. Your Delete is not Correct

      DELETE FROM [Email] WHERE (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))

      the Syntax Supposed to be

      DELETE TABLENAME WHERE [Email] = ? OR [Email] IS NULL

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

      K 1 Reply Last reply
      0
      • V Vimalsoft Pty Ltd

        When you post in CodepProject use the Pre tags, there is a Tool bar for you. This will make us keen to help you. Formating in important. Your Delete is not Correct

        DELETE FROM [Email] WHERE (([Email] = ?) OR ([Email] IS NULL AND ? IS NULL))

        the Syntax Supposed to be

        DELETE TABLENAME WHERE [Email] = ? OR [Email] IS NULL

        Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

        K Offline
        K Offline
        kruegersck
        wrote on last edited by
        #3

        Thanks for the Help! sk

        V 1 Reply Last reply
        0
        • K kruegersck

          Thanks for the Help! sk

          V Offline
          V Offline
          Vimalsoft Pty Ltd
          wrote on last edited by
          #4

          Welcome :)

          Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

          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