.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

sql server how to insert text with syntax words and single quotation?

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :ASP.Net
i would like to insert text in sql server that contains words like select and a single quotation mark but sql server gives errors like if i wanna insert this :

1. Move the cursor to cell A1.
2. Click in the formula area of the Formula bar.
3. Use the backspace key to erase the 's,' 'e,' and "n.'
4. Type ker.
5. Press Enter.

it gives error about the 'use' word and any other word that might be a command or a syntax


View Complete Post

More Related Resource Links

how To Insert the single quotes in sqlcommand in asp.net


Hi all

    i am developed on simple user registeration application in that i gave  address field .when i am trying to enter something like this (1st main,b'lore) but wont take while inserting.

my query is

sqlcommand cmd=new sqlcommand("insert into registeration_form(name,address)values('"+txtname.text+"','"+txt_address+"')",con);

how can i pass the  quotes also to my query please if any one know reply me.


G Dinakaran

T-SQL in Yukon: Powerful New T-SQL Syntax Gives SQL Server a Programmability Boost


The T-SQL language in the upcoming version of SQL Server will provide more power and flexibility than previous versions. Additions and enhancements include error handling with the TRY/CATCH construct, SNAPSHOT isolation, and WAITFOR enhancements. Also important are the BULK rowset provider, common table expressions, recursive queries, PIVOT and UNPIVOT operators, and much more. This article introduces these features so readers will be ready for the next version of SQL Server.

Itzik Ben-Gan

MSDN Magazine February 2004

Insert into SQL Server with ajax file uploader


I am getting error in here 


Incorrect syntax near '987'

987 is where i put clientname.text

        Dim objCmd As New SqlCommand("Create Table " + clientname.Text + "(name Varchar(50), event Varchar(50), date1 datetime, username Varchar(50), password Varchar(50), " + strCommandText + ")", objConn)

        objCmd.CommandType = CommandType.Text

        Dim objConn2 As New SqlConnection("Data Source=dddd.db.2.hostedresource.com; Initial Catalog=mrpoteat; User ID=xxxxx; Password=xxxxxx;")
        Dim strCommandText2 As String = ""
        For index2 = 1 To Attachments1.Items.Count Step 1
            If String.IsNullOrEmpty(strCommandText2) Then
                strCommandText = "@pic" + index2.ToString()

Insert into Sql Server


The following code will Create the Table but Will not do an Insert Into.... Also It will not produce an error

Dim objConn As New SqlConnection("Data Source=mrpoteat.db.2798093.hostedresource.com; Initial Catalog=mrpoteat; User ID=xxxxxxx; Password=xxxxxxxx;")
        Dim strCommandText As String = ""
        For index = 1 To Attachments1.Items.Count Step 1
            If String.IsNullOrEmpty(strCommandText) Then
                strCommandText = "pic" + index.ToString() + Space(1) + "image"
                strCommandText += ",pic" + index.ToString() + Space(1) + "image"
            End If

        Dim objCmd As New SqlCommand("Create Table " + clientname.Text + "(

hsdsd: how to insert two values from text box1 to gridview g



table a

a                                 b

jhgd                           kljhskjd

sdghdshgd                 jkhdjhdjk

what i need is when enter some values(varchar ) in txt 1 and 2

it should be added in database and shown in gridview1 after i press butt1


any bodyknows full code answer/akdj

Insert Excel Data via File Upload into sql server database???

Hi all, I have requirement that User can Upload the Excel Sheet Data to sql server Database at once. How i do that Any Article or hint is apperciated.   Regards 

Insert/Update OLE Attachment(Binary datatype) using SQL server 2000

Hi All, In the same senario how we can Insert/Update OLE Attachment(Binary datatype)  from one source table to other destination table by using SQL Server 2000 not with C# fronend code. Appreciated if you can give fix on this regads, Divakar.

(SQL Server 2008) Exporting entire databases to SQL CREATE/INSERT statements

Hi All, I'm looking for a way to export SQL Server 2008 (Express or otherwise) databases to CREATE/INSERT statements.  I've seen a million threads (give or take) with instructions for creating large (often illegible) TSQL scripts for the task.  However, I'm hoping that this isn't the only way by which to do it.  I have need to regularly back up the data from existing MS SQL Server DBs (which are used by some of our standard apps) to various other MySQL and PostgreSQL databases (which are used by PHP and Rails web front ends).  I need to export them from MS SQL Server 2008 to a general format (i.e. INSERT statements) and perform regex edits on the file as necessary. FYI, I've written a few applications that connect to the various DBs over ODBC, etc. and transfer the data row by row.  You can image how painful this process is... I realize that there are many tools that do this.  However, most of them approach the issue from the standpoint of migration, and not that of regularly scheduled backups.  Also, this tool will need to eventually be distributed so having to purchase a license for the migration app for each person/group simply isn't feasible. Anyway, if you guys have a quality, straightforward solution to this issue, it would certainly be appreciated. Best.

Read a text file on another server from a web page

How do I read/write a text file on another server from a web page. I get the error "Access to the path '//Server2/mydatafiles/test.txt' is denied". I do not get the error if I am running the browser on the server where the files exist. I think I need to set permissions on the destination server in some way.   Can you help? Thanks  

Find text between two separate words - to parse text from a message

Hi all, I am new to regular expressions.   The following text has got three sections; - Name, Date, and Message   [Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on. I would love to see that film. It got great reviews.[Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on.   I want to extract each of them.   The text between "[Sender]:" and  "[Received]:" is the NAME   The next word after the  "[Received]:"  is the DATE   The MESSAGE starts after the digits of the Date end and it is upto the mark  "[Sender]:"   Can anyone tell me how to extract it using C# Regular expressions.   Thank you for your time.   Tomy

Insert Into SQL Server inside a For Each - Next Statement

I have the following code to For each Item in the file uploader, Insert Into database.... but It doesnt work in the For Each Statement but if i take it out of the For Each statement it works.   For Each item As AttachmentItem In Attachments1.Items            Dim objConn2 As New SqlConnection("Data Source=XXX")            objConn2.Open()            Dim objCmd2 As New SqlCommand("INSERT INTO clientport (name, event, date1, username, password, path)" & "VALUES (@name, @event, @date1, @username, @password, @path)", objConn2)                                 objCmd2.Parameters.AddWithValue("@name", clientname.Text)            objCmd2.Parameters.AddWithValue("@event", [event].Text)            objCmd2.Parameters.AddWithValue("@date1", [date].Text)            objCmd2.Parameters.AddWithValue("@username", username.Text)  &nbs

Can you install SharePoint 2010 and User PerformancePoint in a single server enviroment?

Hi I Installed SharePoint 2010 in a single server farm and I configured a Performance Point service aplication. Whenever I run dashboard designer it seems to work but it eventually crashes. I don´t know if I have any configuration errors. I read this Run the Secure Store Service on a separate application server that is not used for any other service. Create the secure store database on a separate application server running SQL Server. Do not use the same SQL Server installation that contains content databases. Here http://technet.microsoft.com/en-us/library/ee806889.aspx I believe this service is necesary to run connect to data sources does this mean it all cannot be run in the same server.

Single Server URL Name Configuration

I have created a 2 Server Farm (WFE/App and SQL) and created a Active Directory Domain (DEV.local) and DNS (DEV.Local) and set up my first site collection via the wizard after install and it works great as hhtp://servername and then I wanted to create a new site http://portal.dev.local and I am having no luck as I must be doing things out of order. I created a Managed Account, Web Application, Site Collection and I can not access it. I created an A Record and then a N Record in DNS and tried to set up Alternate Access Mapings and still no luck.  Is there some documentation on setting this up with a single IP/Machine? Thanks, ReevesDenver, CO

insert query from ms SQL server into a mysql linked server

INSERT into openquery(dbserver1MySQL,'select * from graham.lookup_in_table') select * from NavteqAPAC.dbo.Admin_Names   is giving me the following error! Please help me   OLE DB provider "MSDASQL" for linked server "dbserver1MySQL" returned message "[MySQL][ODBC 5.1 Driver][mysqld-5.1.49-community]Commands out of sync; you can't run this command now". Msg 7343, Level 16, State 2, Line 1 The OLE DB provider "MSDASQL" for linked server "dbserver1MySQL" could not INSERT INTO table "[MSDASQL]".

Insert 5000 records to Sql server using ado.net at once

Question Details:-I have 2 databases. DB1 and DB2DB1 contains a table having colums.   1. TF2. OD3. SD4. FD5. ES6. EF7. Comments-------------------------------DB2 table TB1 has the same fields but diff column names1. TotalFloat 2. OriginalDuration 3. StartDate 4. FinishDate 5. EearlyStart 6. EearlyFinish7. strComments__________________________________DB1 table has arround 7000 rows. What my requirement is: Copy all the rows from DB1.TB1 into DB2.tblTargetWhat I am doing is?Looping all the records from the db1 table and by using InsertCommand adding all thoses records to a dataset.Now using Adapter.Update method,,,, all the records are fethecd to target database table. but when Adater.Update() method executes, it paused there for 3-5 minutes.Can I acheieve this in a quick manner? Please help me out of this, as this ia very critical task.I would like  to achieve this via coding.Thanks and Best Regards,Dev

error in insert hebrew data into sql server 2005

Hello, am trying to insert data in hebrew language into sql server 2005 but it appears like this ???????????? can i know how i can fix the problem plz???? thank u


Hi Friends, I am creating an application for a jewellery shop (MINOR PROJECT) in VB.Net but my problem is that I dont know how to insert multiple records for same bill number. consider the following condition Bill Number Customer Name   ............................................... Customer Address ................................................ S.No                 Item name                Rate    Qty                            Total 1                      abc                            5        5                                 25 2                 &nb
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend