I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).

I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).Yes i have inserted a row in the table. Now i have got the values " arun's ", 50.                 insert into Table values('arun's',20)  My sqlserver is giving me an error instead of inserting the row. How will you solve this problem?  

 

0
kbs
2/1/2008 4:56:57 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
986 Views

Similar Articles

[PageSpeed] 55

The direct answer to your question is: You insert it like this:

    insert into Table values('arun''s',20)

However, please show us your code that is generating the INSERT statement, as we will have suggestions for you to avoid this issue safely and completely.


Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
2/1/2008 5:16:44 AM

The problem is not with the database,with the code. Plz provide the aspx.vb or .cs code

Thank u

Baba
 


Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you.
0
srijaya_ramaraju
2/1/2008 6:39:54 AM

srijaya_ramaraju@yahoo.com:

The problem is not with the database,with the code. Plz provide the aspx.vb or .cs code

Thank u

Baba
 

This is not a problem with either the database or the code. It is simply lack of validation in code which allows some special characters such as a single quote, double quote etc. Eihter, the code should handle such characters by validating the user data for such characters or mechanism needs to be provided in the code to accept such data by checking a known list of such characters which needs to be pre-defined and then.

I suggest using Parametrized queries.


-----------------------------------------------
Please click Mark as Answer if this helped.
0
aparnagarg
2/1/2008 8:14:30 AM
Reply:

Similar Artilces:

Is having a trigger that inserts a row in Table 'A', when a row in same table is inserted by ADo.Net code?
I want to insert a row for a Global user  in Table 'A' whenever ADO.Net code inserts a Local user row into same table. I recommended using a trigger to implement this functionality, but the DBA was against it, saying that stored proecedures should be used, since triggers are unreliable and slow down the system by placing unecessary locks on the table. Is this true OR the DBA is saying something wrong? My thinking is that Microsoft will never include triggers if they are unreliable and the DBA is just wanting to offload the extra DBA task of triggers to the programmer so that a s...

getting the error: Cannot insert the value NULL into column 'name', table 'InterGlobe.dbo.IG_Admin'; column does not allow nulls. INSERT fails. The statement has been terminated.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <script runat="server">   private void CrLogin_Click(object source, EventArgs e) {   try { //Response.Write("hello"); SqlDataSource2.Insert(); // Response.Redirect("logincreated.aspx"); } catch(Exception ex) { Response.Write(ex.Message); }   } </script>       <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">       &nbsp;<a...

How to INSERT INTO [Table] ([Field]) VALUES('I Have a ' in value')
Hi, I want to INSERT INTO [Table] ([Field]) VALUES('I Have a ' in value') please teach me how to xxx INSERT INTO [Table] ([Field]) VALUES('I Have a '' in value') instead of one single quote, u need to add one more.Om Prakash Use Parameterized Queries ...you woudnt have to worry about escape characters besides saving your db from sqlinjection attacks. hth***********************Dinakar NethiLife is short. Enjoy it.***********************...

DetailsView Insert Error: Cannot insert the value NULL into column 'customer', table 'DEMO
Using VWD Express edition creates a page(Default.aspx) with a Dropdownlist for selecting a customer and a GridView to show the details of the selected customer and to edit and delect a customer's detail. I add a button to link to page Add.aspx for add a new record. I add a DetailsView and the following code so it goes to New record mode when page loads:        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)               DetailsView1.ChangeMode(Det...

Error in Tutorial DetailsView"Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSERT fails.
Hi,I am trying to do the insert part of detail's view Tutorial (the last one) and I received this error: "Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSERT fails.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'contract', table 'pubs.dbo.authors'; column does not allow nulls. INSER...

Inserting Data Into Two Tables (Getting ID from Table 1 and inserting into Table 2)
I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.  Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)  This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!  Insert Table1(Title,Description,Link,Whatever)Values(@title,@descri...

Error: Primary key for row in table 'x' is referenced by foreign key 'f' in table 'y'
(ASA 9 newest ebf) I'm getting this error even though mentioned foreign key has cascade updates (and deletes too) enabled. Is this some new behaviour in asa 9, or why can i get such message for cascaded foreign key? Any ideas? Thanks Pete Found a reason for it...but should it really work so? It's this way: - table a has columns a,b,c - table b has columns a,c, and references columns a,c (with a,c) in table a with cascade updates - table a hes before update trigger to change columns a when column b is changed (set new_row.a = ...) and that set new_row.a = ... i...

Empty 'inserted' table in insert trigger
I have a table with insert trigger. Inside the trigger, I write records from the inserted table to another table. However, I found that the inserted table is empty. Any Idea? I am using ASE 12.5.0.3 Thanks in advance. not impossible. something like: insert tbl select * from other_tbl where 1=2 would fire the trigger, but not insert any rows, and have no corresponding rows in the inserted table. <Vicky> wrote in message news:4330d6dd.2d0a.1681692777@sybase.com... > I have a table with insert trigger. Inside the trigger, I > write records from the inserted tabl...

Unable to create table 'table name' because it has no remote storage location define error
I'm working with Sybase 11.5.1. Few days ago I changed the configuration parameters 'enable CIS' and 'cis rpc handling' to 1 and right now this seems to damage my Database, because I can't create tables on any of my databases, only tempdb and master are allowed to do so. When I tried to create a table the following error appears 'Unable to create table 'table name' because it has no remote storage location define. Creation of local user tables is allowed only in the master and tempdb Databases.' I checked at Sybase.com and refering to this ...

If one creates a table including PortalID, ModuleID and UserID, and for some records, they are 'global', like 'all portals', 'all modules', or 'all users'...
Is there standard in DNN for a default number?  I know that UserID of -1 is nono, because this means (I think) Host user, correct?  And PortalID of 0 is default portal.  What is safe default number to use in those records?  I searched through source code for DNN, all are hardcoded numbers, no 'DEFAULT_ALLPORTALS As Integer = x' or like that.  Does anyone have suggestion on what I use?  Is only alternative for NULL (which make query more difficult)?  I purchased the? book on DotNetNuke, and hope that some of these infos I would find, but it is mild t...

Inserted records missing in sql table yet tables' primary key field has been incremented.
I have a sql sever 2005 express table with an automatically incremented primary key field. I use a Detailsview to insert new records and on the Detailsview itemInserted event, i send out automated notification emails. I then received two automated emails(indicating two records have been inserted) but looking at the database, the records are not there. Whats confusing me is that even the tables primary key field had been incremented by two, an indication that indeed the two records should actually be in table.  Recovering these records is not abig deal because i can re-enter them but ia...

Providers: 'user' table vs 'aspnet_Users' table
Hi, I'm starting to write a set of custom providers- Membership, Role, and Profile.  The Membership provider accesses a table called 'user', and I just noticed that the 'Profile' provider appears to call a similarly named table called 'aspnet_Users'.  Are these tables similar in purpose?  I don't understand why the Profile provider would access a membership table other than the 'user' table; I'd prefer to ignore the 'aspnet_Users' table, but I doubt that it's possible. Can anyone explain how these tables are different or related in the overall provider model? B...

Update unable to find TableMapping['Table'] or DataTable 'Table'
hi! i got the following error message while trying to update an access db: Update unable to find TableMapping['Table'] or DataTable 'Table' i have the following code in my application: IDbDataAdapter yadAdapter = new OleDbDataAdapter(); OleDbCommand yadCommand = new OleDbCommand(); yadCommand.Connection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=c:/inetpub/wwwroot/yad/Data/ASPNetDB.mdb"); yadAdapter.TableMappings.Clear(); yadAdapter.TableMappings.Add("NV", nvTable.ToString()); yadAdapter.TableMappings.Add("FV",...

Create Dynamic Table and Insert values to it from existing table
Hi Guys,  Need some help with the sql statement for this one. I want to create a dynamic table and then after that I will insert data into that created table from an existing table. It's like making a back up of a certain table on my database. I really appreciate any help from you guys. Thanks. select * into <DestinationTableName> from <SourceTableName>The above query will create a new table with the name specified as <DestinationTableName> and populate the data from the <SourceTableName> in it.The ideal way of doing this would be to:First create a t...

Web resources about - I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20). - asp.net.sql-datasource

Resources last updated: 12/9/2015 10:02:46 AM