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. i need to add a mailto string into an access db but get this error

i need to add a mailto string into an access db but get this error

Scheduled Pinned Locked Moved ASP.NET
databasequestionhelp
9 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.
  • R Offline
    R Offline
    robmays
    wrote on last edited by
    #1

    "Syntax error (missing operator) in query expression ''pop1@tes.co.uk''." i use this method to build string private string buildMailToString(string email) { //phil string newMail = ""; if(email.Length >0) { newMail = @"[" + email.Trim() + "](mailto:" + email.Trim() + ")"; } return newMail; } and this for the insert private void btnAdd_Click(object sender, System.EventArgs e) { string email1 = buildMailToString(txtEmail1.Text.Trim()); string email2 = buildMailToString(txtEmail2.Text.Trim()); string email3 = buildMailToString(txtEmail3.Text.Trim()); if((this.txtCustomerID.Text == "0") || (this.txtCustomerID.Text == "")) { string sql = "INSERT INTO Customers(Title,Initials,Firstname,Lastname,HomeNumber," + "WorkNumber,Mobile,Fax,Email1,Email2,Email3,Notes) Values('" + this.txtTitle.Text + "','" + this.txtInitials.Text + "','" + this.txtFirstname.Text + "','" + this.txtLastname.Text + "','" + this.txtHomeNumber.Text + "','" + this.txtMobile.Text + "','" + this.txtWorkNumber.Text + "','" + this.txtFax.Text + "','" + email1 + "','" + email2 + "','" + email3 + "','" + this.txtNotes.Text + "')"; OleDbCommand cmd = new OleDbCommand(sql,cnn); try { cnn.Open(); cmd.ExecuteNonQuery(); how do i build the string correctly?????

    R G 2 Replies Last reply
    0
    • R robmays

      "Syntax error (missing operator) in query expression ''pop1@tes.co.uk''." i use this method to build string private string buildMailToString(string email) { //phil string newMail = ""; if(email.Length >0) { newMail = @"[" + email.Trim() + "](mailto:" + email.Trim() + ")"; } return newMail; } and this for the insert private void btnAdd_Click(object sender, System.EventArgs e) { string email1 = buildMailToString(txtEmail1.Text.Trim()); string email2 = buildMailToString(txtEmail2.Text.Trim()); string email3 = buildMailToString(txtEmail3.Text.Trim()); if((this.txtCustomerID.Text == "0") || (this.txtCustomerID.Text == "")) { string sql = "INSERT INTO Customers(Title,Initials,Firstname,Lastname,HomeNumber," + "WorkNumber,Mobile,Fax,Email1,Email2,Email3,Notes) Values('" + this.txtTitle.Text + "','" + this.txtInitials.Text + "','" + this.txtFirstname.Text + "','" + this.txtLastname.Text + "','" + this.txtHomeNumber.Text + "','" + this.txtMobile.Text + "','" + this.txtWorkNumber.Text + "','" + this.txtFax.Text + "','" + email1 + "','" + email2 + "','" + email3 + "','" + this.txtNotes.Text + "')"; OleDbCommand cmd = new OleDbCommand(sql,cnn); try { cnn.Open(); cmd.ExecuteNonQuery(); how do i build the string correctly?????

      R Offline
      R Offline
      robmays
      wrote on last edited by
      #2

      newMail = "[" + email.Trim() + "](mailto:" + email.Trim() + ")"; the string shows better here

      1 Reply Last reply
      0
      • R robmays

        "Syntax error (missing operator) in query expression ''pop1@tes.co.uk''." i use this method to build string private string buildMailToString(string email) { //phil string newMail = ""; if(email.Length >0) { newMail = @"[" + email.Trim() + "](mailto:" + email.Trim() + ")"; } return newMail; } and this for the insert private void btnAdd_Click(object sender, System.EventArgs e) { string email1 = buildMailToString(txtEmail1.Text.Trim()); string email2 = buildMailToString(txtEmail2.Text.Trim()); string email3 = buildMailToString(txtEmail3.Text.Trim()); if((this.txtCustomerID.Text == "0") || (this.txtCustomerID.Text == "")) { string sql = "INSERT INTO Customers(Title,Initials,Firstname,Lastname,HomeNumber," + "WorkNumber,Mobile,Fax,Email1,Email2,Email3,Notes) Values('" + this.txtTitle.Text + "','" + this.txtInitials.Text + "','" + this.txtFirstname.Text + "','" + this.txtLastname.Text + "','" + this.txtHomeNumber.Text + "','" + this.txtMobile.Text + "','" + this.txtWorkNumber.Text + "','" + this.txtFax.Text + "','" + email1 + "','" + email2 + "','" + email3 + "','" + this.txtNotes.Text + "')"; OleDbCommand cmd = new OleDbCommand(sql,cnn); try { cnn.Open(); cmd.ExecuteNonQuery(); how do i build the string correctly?????

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Use quotes instead of apostrophes in the html code. But you should protect your code against SQL injections anyway. Otherwise you might be in for an unpleasent surprise... --- b { font-weight: normal; }

        R 1 Reply Last reply
        0
        • G Guffa

          Use quotes instead of apostrophes in the html code. But you should protect your code against SQL injections anyway. Otherwise you might be in for an unpleasent surprise... --- b { font-weight: normal; }

          R Offline
          R Offline
          robmays
          wrote on last edited by
          #4

          using quotes makes the string break up as there is a string within a string? ie newmail = "" + email.trim()+ ""; wont compile????

          G 1 Reply Last reply
          0
          • R robmays

            using quotes makes the string break up as there is a string within a string? ie newmail = "" + email.trim()+ ""; wont compile????

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Use \" to put a quote in a string. --- b { font-weight: normal; }

            R 1 Reply Last reply
            0
            • G Guffa

              Use \" to put a quote in a string. --- b { font-weight: normal; }

              R Offline
              R Offline
              robmays
              wrote on last edited by
              #6

              fantastic just what i neede worked a treat, goes into database lovely but now i need to tidy it up when i bring it back out as asp.net throughs a huge wobly when i try to save it on the page as it has charac it does not like so i think i need to get rid of the \ to display it back on the page, any ideas?

              G 1 Reply Last reply
              0
              • R robmays

                fantastic just what i neede worked a treat, goes into database lovely but now i need to tidy it up when i bring it back out as asp.net throughs a huge wobly when i try to save it on the page as it has charac it does not like so i think i need to get rid of the \ to display it back on the page, any ideas?

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                There isn't any \ in the string. The escape sequence \" just puts the character " into the string. What do you mean by "asp.net throughs a huge wobly"? Barely half of those are real words... --- b { font-weight: normal; }

                R 1 Reply Last reply
                0
                • G Guffa

                  There isn't any \ in the string. The escape sequence \" just puts the character " into the string. What do you mean by "asp.net throughs a huge wobly"? Barely half of those are real words... --- b { font-weight: normal; }

                  R Offline
                  R Offline
                  robmays
                  wrote on last edited by
                  #8

                  i am trying to get asp.net make a hyperlink in a datalist so i need to put the whole maito: tag into the database so AS WHEN IT IS READ BACK OUT Again it create a mailto in the datalist. the data list is smart enough to convert the tag into html and work fine, but when the details are seen in a textbox on its own the whole of the mailto tag appears in the textbox and when you hit save asp.net goes crazy so it does not like things like this being saved test\"" saving that sort of text in a textbox to a database blows up!!! so i had to clean the text up from the database all is working well thanks to you.:)

                  G 1 Reply Last reply
                  0
                  • R robmays

                    i am trying to get asp.net make a hyperlink in a datalist so i need to put the whole maito: tag into the database so AS WHEN IT IS READ BACK OUT Again it create a mailto in the datalist. the data list is smart enough to convert the tag into html and work fine, but when the details are seen in a textbox on its own the whole of the mailto tag appears in the textbox and when you hit save asp.net goes crazy so it does not like things like this being saved test\"" saving that sort of text in a textbox to a database blows up!!! so i had to clean the text up from the database all is working well thanks to you.:)

                    G Offline
                    G Offline
                    Guffa
                    wrote on last edited by
                    #9

                    robmays wrote: asp.net goes crazy robmays wrote: saving that sort of text in a textbox to a database blows up I assume that you don't mean what you write. As asp.net is not an intelligent being, it can hardly go crazy. I don't believe that saving some text can cause any sort of explosion either. So what do you mean? If you get an error message, it would be helpful if you shared it. Otherwise I can just keep guessing what's happening. robmays wrote: test\"" You have to use the pre tag for the code to show up in the post. --- b { font-weight: normal; }

                    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