Insert SQL on Sql Command

i'm using an sql command for insert query

it looks like this
cmd=new sqlcommand("insert into tblname values('" & textbox1.text & "')",cn)
cmd.executereader
the problem is if i type a singlequote or double quote an error is throwing,invalid syntax ....

how can i s'rt out it with out using a sql stored procedure

thanks in advance
PrasantH
I think therefore i'm

vPras©
0
mrp123
10/5/2003 1:46:38 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
763 Views

Similar Articles

[PageSpeed] 58

Hi,

try replacing the single quotes present in your input with double single quotes ... example below:
string sqlInput = textbox1.text.Replace("'","''");

In the above code what I have done is that I have replaced all single quotes (') with two single quotes (''). The Sql database will store a single quote when i encounters two single quotes in your query. Hope this solves ur issue.
CreProDes
0
CreProDes
10/5/2003 2:42:26 PM
you dont have to worry about it if you use parameterized queries..
***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
10/6/2003 3:28:38 AM
Reply:

Similar Artilces:

how do i insert data into sql server using data from textboxes and sql connection and sql command
anyone can give me a simple explaination and code.. Thanx in advance Take a look @ Sample Code: How to add...Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb There are a lot of tutorials out there, but I know they can be a bit confusing as they all approach things slightly differently. Basically a nice simple version would go like this:' *** First set up your connectionDim conConnection As New SqlConnection("server=servername;database=yourdatabase;uid=yourname;pwd=yourpassword;")' *** This line takes care of your sommand text and command connection in one ...

INSERT data into SQL table... TableAdapter Commands or SQL Commands? Which is best?
I've been working on some unbound data forms, and trying to decide what is best when inserting and/or updating a record into a SQL table.    I can successfully use SQL commands to insert data from VS2008 into a sql table on the server, doing something such as... Dim conn As New SqlConnection("server=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=YourDatabaseName")Using conn conn.Open() Dim cmd As New SqlCommand("UPDATE tableName SET folderName = @folder WHERE id = @id", conn) cmd.Parameters.AddWithValue("@folder", txtFolder.Te...

what's difference between Accesss DataBase and Sql Sever about Sql String(or Command),Sql StoreProcedure ?
i am being dirty to Access DataBase from Sql Sever Database for my new work.But the sql string of Access sounds like a little different,can i use  the sql string of SqlSever for Access database,too?another question is: Does Access DataBase support Sql StoreProcedure??? when i worked in Access2000 ,did not see any about StoreProcedure,but i download a file named AccessHelper.cs  , some function of it looks like support StoreProcedure,Does it?  i want to fly ... Hi dkzeng ,Your first question     The string of both sqlsever and acce...

SQL > My SQL
I have a problem, my asp.net page wants to connect to the sql server, but it has to be the mysql. How can I solve this problem? This is my code: <%@ page explicit="true" language="VB" debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.Odbc" %> <%@ Import Namespace="System.Data.SqlClient" %> <html> <script runat="server"> sub page_load(sender as object, e as eventargs) If Not IsPostBack Then dim connect as sqlconnectio...

SQL Express to SQL ?
I am developing a site using the express edition of all tools (VWD and SQL Express).  I want to use GoDaddy hosting and was wondering if I will be able to effectively put my SQL database and website up on their hosting even though it was developed via Express edition of Microsoft programs?...

sql or my sql query
hi,in my database  i have the two tables...1)programs                                2)reservedin the programs...two fields 1)program id           2)maxseats................these details wil be entered by adminin the reserved table  two fileds ..1)PRogramid        2)statusmy requirement is .. i need the available seats..meansif any body is intersted in  any program...they wil select the program...then status becomes approved(1)..then i need the o/p as ...

SQL A and SQL Server
Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL Anywhere, therefore, similar to SQL Server? -- Regards, John Not quite true. SQL Anywhere was created by Watcom. SQLServer was created by Sybase, and Microsoft licensed the technology. So MSSQL and ASE have common roots, not SQLAnywhere. -- Paul Horan[TeamSybase] "John Kingan" <john.kingan@abibuildingdata.com> wrote in message news:40d82aa1$1@forums-1-dub... > Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL > Anywhere, therefore, similar to SQL Ser...

when to use sql update and sql insert
I have a page where the user can update stock records. it has 5 x 5 text boxes. If the user has already entered stock before that stock will show up and they can change it and clicking the button it will update, however if they have just entered new data i would assume they would need to insert it, so how do i go about doing this? do i need to use both insert and update in the same sql string?Jeremy HusonSenior Network EngineerCarden Computers - PC Repair Brighton Hi,   Generally in such a situation we normally differentiate  the records for updation and inserion through the...

sql paramaters, preview sql command
hey people i have this code:SqlCommand cmdIns = new SqlCommand(sqlIns, conexion);cmdIns.Parameters.Add("@usuario", TextBox1.Text);cmdIns.Parameters.Add("@contrasena", TextBox2.Text);cmdIns.Parameters.Add("@tipo", DropDownList1.SelectedValue);... and well i would like to see the SQL command that will be executed before i run it, is there any method that can get it?the most ive gotten is the original command with  the paramaters with @, not the valuessorry for my englishthanks in advance  You can check Sql command by cmdIns.CommandText  ...

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

Insert command in SQL with vb.net
Hi I am a new in ASP .NET programming I faced a problem to insert integers with other types of variables in my database from my programs. I have only permission to pass the SQL command to my server. As an example I have one table TestTable with two column one is integer and one is varchar named as ID and Fname I can insert any string that table but when I trying to insert integer and string then it shows an error.Dim strInsertSQL As String = "INSERT INTO TestTable (ID,Fname) VALUES (" & iID & “,’” & strFname & “’)”Dim conStr As String = String.EmptyconStr = Confi...

Variable Insert to SQL server insert satement setting values for the @variable INSIDE sql
ok, I am on Day 2 of being brain dead.I have a database with a table with 2 varchar(25) columns I have a btton click event that gets the value of the userName,  and a text box.I NEED to insert a new row in a sql database, with the 2 variables.Ive used a sqldatasource object, and tried to midify the insert parameters, tried to set it at the button click event, and NOTHING is working. Anyone have a good source for sql 101/ASP.Net/Braindead where I can find this out, or better yet, give me an example.  this is what I got <%@ Page Language="C#" %><!DOCTYPE html ...

SQL code to stop and restart sql server 2005 and sql agent
Hi. I would like to restore a SQL Server 2005 database from a backup file. The problem is that the users which are using the site, prevent the restore operation from completing. So, I stop the sql server by right clicking the server name in management studio and selecting stop, wait for 3-4 minutes and restart it by clicking start. Then I can restore. So I am looking for code that can do these operations (including the wait). let me just add that I am using a named instance - and I want to stop and restart the instance. Please help, thanks in advance. I found this link http://...

Announce: BNF Grammars for SQL-92, SQL-99 and SQL-2003
Hi Folks Jonathan Leffler has sent me these grammars, which I'm hosting at: http://savage.net.au/SQL/ -- Cheers Ron Savage, ron@savage.net.au on 17/07/2005 http://savage.net.au/index.html Let the record show: Microsoft is not an Australian company At 11:08 AM +1000 7/17/05, Ron Savage wrote: >Hi Folks >Jonathan Leffler has sent me these grammars, which I'm hosting at: >http://savage.net.au/SQL/ Thanks for posting that; should be very useful. I will point out an apparent spelling mistake, though. See http://savage.net.au/SQL/sql-2003-noncore-feat...

Web resources about - Insert SQL on Sql Command - asp.net.sql-datasource

Command - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Cameron Carpenter review: Bells and whistles matched by a command of the organ
It's certainly no exaggeration to call Cameron Carpenter's command of six keyboards (five for hands, one for feet) "genius". Purely in cognitive ...

Adele eclipses Taylor Swift to take command of the pop world
Adele Adkins is the first person to top the ARIA singles and albums charts in the same week since Swift exactly one year ago.

Command your club to victory in Sega’s Football Manager Mobile 2016
... How long can you survive on the Last Horizon? , and Dig, explore and collect stars in Starlit Adventures . Football Manager Mobile 2016 Command ...

How to craft your own custom voice commands for Amazon Echo's Alexa
With a little help from IFTTT, you can teach Alexa all sorts of new tricks. Here's how to get started.


Bethesda: Fallout 4 console commands 'not supported or recommended' on PC
In a very Bethesda-like fashion, messing around with console commands on the PC version of Fallout 4 might completely bug out your game more ...

Amazon Echo owners can create custom voice commands with IFTT
... item to your shopping list is pretty cool, but there comes a point where you start to feel the limits of the Echo's pre-programmed voice commands. ...

Huckabee: Don't Settle for Minimum Wage, Work to Command a Maximum Wage
In his opening remarks last night, Mike Huckabee said proposals to raise the minimum wage in several states will not bring prosperity and independence ...

Amazon Echo gets customizable voice commands thanks to deeper IFTTT integration
While Amazon’s Echo can tell you about traffic and control your smart-home devices, users haven’t had much ability to develop their own commands ...

Resources last updated: 11/29/2015 6:27:14 PM