Web Form does not accept (single quote character) when saving to Access Database

ASP.net 1.1 with VB
Database: MS Access

When saving Text to a datbase via web forms I get an error if the text contains the character (single quote)

Syntax error (missing operator) in query expression
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression '

How can I solve this?

0
sunhuman
3/25/2008 3:50:22 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

12 Replies
854 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store


ValidateRequest="false"
add this attribute in page register tag of .aspx page. If you still get the problem post the SQL query


Watch The true story of internet ||Yet another forum |||
I'm big fan of Open source flash chart for .net very very simple
I n t e r v i e w T i p s
0
satalaj
3/25/2008 4:50:37 AM

 Hi,

Refer the same post of this forum.

http://forums.asp.net/t/1058874.aspx 


Shah Dharnendra G
Sr.Analyst Programmer,
GTL-Ahmedabad
0
dharnendra
3/25/2008 6:31:49 AM

sunhuman:

ASP.net 1.1 with VB
Database: MS Access

When saving Text to a datbase via web forms I get an error if the text contains the character (single quote)

Syntax error (missing operator) in query expression
System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression '

How can I solve this?


Hi sunhuman  ,

Can you post your sql statement query here so that we can check it out..



Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/25/2008 6:35:59 AM

Thanks for the reply. But it did not help.

Below is the code I use to update.

cnaConn.Open()

Dim cmdCNA10 As New OleDbCommand

cmdCNA10.CommandText = "update admin_recommendations set status='" & strStatus & "',completed_date='" & strCompletedDate & "' where recommendation ='" & strRec & "' "

cnaAdapter.UpdateCommand = cmdCNA10

cnaAdapter.Fill(dsCNA, "UpdateAdmin")

cmdCNA10.CommandType = CommandType.Text

cmdCNA10.Connection = cnaConn

------------------

This command works absolutely fine, but gives error only when I enter (single quote) when updating database field (status)

 

 

0
sunhuman
3/25/2008 7:12:56 AM

:

This command works absolutely fine, but gives error only when I enter (single quote) when updating database field (status)

Why not validate the Users Input for not allowing single quotes? another is try using + sign instead of & so its something like this

cmdCNA10.CommandText = "UPDATE admin_recommendations set status='" + strStatus + "' AND completed_date='" + strCompletedDate + "' AND recommendation ='" + strRec + "' "

 



Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/25/2008 7:51:41 AM

before you assign the commandtext..

do like this

string s =  strStatus;

response.write( s.Replace("'"," ");  -- This is will replace all ' present in Strstaus to " "

 

Hope this may help you..


With Thanks.,
R.Chezhian.,
=============================================
Please Mark the helpful post(s) as Answered
0
chezhian_in05
3/25/2008 8:14:40 AM

Use String.Format

String.Format("update admin_recommendations set status='{0}',completed_date='{1} ' where recommendation ='{2}',strStatus,strCompletedDate,strRec)

 

Its clean, readable and less error prone to other techniques

0
abhiramvikrant
3/25/2008 8:23:40 AM

Use String.Format

String.Format("update admin_recommendations set status='{0}',completed_date='{1} ' where recommendation ='{2}',strStatus,strCompletedDate,strRec)

 

Its clean, readable and less error prone than other techniques

0
abhiramvikrant
3/25/2008 8:24:41 AM

Use String.Format

String.Format("update admin_recommendations set status='{0}',completed_date='{1} ' where recommendation ='{2}' ",strStatus,strCompletedDate,strRec)

 

Its clean, readable and less error prone than other techniques

0
abhiramvikrant
3/25/2008 8:26:05 AM

Sorry this has not helped solve the problem

0
sunhuman
3/25/2008 8:42:34 AM

Use stored procedure or pass them as sql parameter it will solve ur prob

For eg

string strquery;

strquery="Select * from emp where name=@Namae"

 

 

cnaConn.Open()

Dim cmdCNA10 As New OleDbCommand

cmdCNA10.CommandText = "update admin_recommendations set status=@Status,completed_date=@strCompletedDate where recommendation =@ strRec "

cmdCNA10.Parameters.Add(@Status , db_type).Value="Abc's"

similarly add other parameter and exec the command

cnaAdapter.UpdateCommand = cmdCNA10

cnaAdapter.Fill(dsCNA, "UpdateAdmin")

cmdCNA10.CommandType = CommandType.Text

cmdCNA10.Connection = cnaConn

 

I hope this will solve ur problem.


Alok
0
aloksinha83
3/25/2008 9:59:24 AM
Reply:

Similar Artilces:

Accessing two web forms in a single web form
  Hi. I am developing a website in VS 2005 with Ajax & SQL Server. I am having 5 forms in my application. 1) Login Form 2) Main form 3) Form "A" 4) Form "B" I need to show the main form after the User login. I need to show all the contents of form A or form B (Ex: Form "A" user or form "B" user) in the Main Page. Can I show a single page having Main Form controls as well as Form "A" and Form "B" controls? I should access all the controls including Form A/B in the Main Page. Thanks ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Multiple "Forms" in a Web Form.
Hi, this query relates to ASP.NET 2.0. I use C# but answers in C# or VB.Net is fine. I have a form to capture a person's details. The form is the usual forename, surname, etc. and the Person is held in a Person Class. What I want to be able to do is to move the form creation into a Class in a separate Class in App_Code. This will enable a button to be placed on the web form to "Add Another Person" using the class. This would create a new Person object and write a new form into the page for the second person to fill in their details. Naturally, this could continue to n Pe...

superreview denied: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Mark Mentovai <mark@moxienet.com> has denied Stuart Morgan <stuart.morgan@alumni.case.edu>'s request for superreview: Bug 410500: Add "Web form password" description to web form keychain items https://bugzilla.mozilla.org/show_bug.cgi?id=410500 Attachment 295140: fix https://bugzilla.mozilla.org/attachment.cgi?id=295140&action=edit ------- Additional Comments from Mark Mentovai <mark@moxienet.com> Not localizable :( ...

superreview requested: [Bug 410500] Add "Web form password" description to web form keychain items : [Attachment 295140] fix
Stuart Morgan <stuart.morgan@alumni.case.edu> has asked Mark Mentovai <mark@moxienet.com> for superreview: Bug 410500: Add "Web form password" description to web form keychain items https://bugzilla.mozilla.org/show_bug.cgi?id=410500 Attachment 295140: fix https://bugzilla.mozilla.org/attachment.cgi?id=295140&action=edit ...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

calling a web form from another web form
I would like to know what is the best way to open a web form from another web form. I would like to call it from a button control. Thanks Well, if I've grasped your question right, there are many methods to do that: 1)Response.Redirect > To navigate to another page from code and is equal to clicking a hyperlink. I suggest this as I think it's closer to your question. 2)Server.Transfer > This ends the current web form and begins a new web form. It's usable when you want to pass some variables i.e (Label1.Text) to the next immediate page. It's not safe though and not used to send p...

Web Form vs. Web Content Form
If you don't mind, I would like to know what is the difference between those two items, when I go to add a new item I see both of those and I don't know what the difference is.  A content form is for use with a masterpage. A web form is a standalone web page. If you select web content form, you will then have to specify a masterpage for it. and what is a master page used for?  Hi, a master page is used to give a constant look and theme to a site, without having to duplicate code. So basically you can put your header, menu, nav and footer on a master page. Then a...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Include web form inside web form
I tried to include an aspx file in a asp.net web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Web resources about - Web Form does not accept (single quote character) when saving to Access Database - asp.net.web-forms

Dilbert (character) - Wikipedia, the free encyclopedia
Dilbert is a fictional character and the main character and protagonist of the Dilbert comic strip . He is a white collar office worker who has ...

Twitter CEO Winks at Change to 140-Character Limit
Twitter might soon let people post tweets that are longer than 140 characters. Extra characters will likely be shoved into expandable cards. ...

Twitter seems intent on increasing the character limit for tweets
Twitters 140-character limit for tweets could soon be a thing of the past. According to a new report from Re/Code , Twitter is planning to substantially ...

Would dropping the 140-character limit completely change the face of Twitter?
... be on the verge of making one of the most significant changes in its history. The micro-blogging service has long been famed for its 140-character ...

Twitter hints that the 140-character limit is coming to an end
Just hours after Re/code published a report on Tuesday revealing that Twitter's 140-character restriction would soon be abolished, Twitter CEO ...

Anyone who hates the idea of Twitter lifting its 140-character limit is being ridiculous
If you use Twitter a lot, you're either really excited or really appalled by the idea that Twitter might soon ditch its 140 character limit. ...

Twitter overhaul? Your tweets could soon be 10000 characters long
CBS News Twitter overhaul? Your tweets could soon be 10000 characters long CBS News Tweets are known for their brevity, and at 140 characters ...

Twitter may expand 140-character limit
Twitter may be getting ready to allow tweets with more than 140 characters. A lot more. Re/Code and other sites reported today that Twitter ...

Twitter May Finally Be Getting Rid Of 140-Character Limit On Tweets
... Twitter user, you’re likely familiar with the restriction that limits the expression of every thought, comment, and desire to a mere 140 characters. ...

Twitter Might Increase Character Limit to 10K
Tweets may appear as if they are 140 characters, but have an option to expand to see the rest, if there's more.

Resources last updated: 1/6/2016 6:16:36 PM