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


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character ...

Posted By:      Posted Date: September 25, 2010    Points: 0   Category :ASP.Net
 

Can someone please review my code and see where I can be missing information. I get the following error:

Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character string ' )'. at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQuer yTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.SaveToDatabase(String SavePath) in C:\Inetpub\wwwroot\Webfile1\Default.aspx.vb:line 78


Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Submit1_Click(ByVal sender


View Complete Post


More Related Resource Links

Unclosed quotation mark after the character string '

  

insert into quality_assurance (person_id, last_name) values ('"+id.text+"','"+last_name.text+"')

id.text and last_name.text are fields in our specialized scanning application and that's how you would extract the values in them to pass them into a sql server query.

The challenge now is that when the last_name.text = a name with a single quote, I get the error above "Unclosed quotation mark after the character string ' "

Any ideas?

 

 


Unclosed quotation mark after the character string ')

  
Hi,


I am getting the error "Unclosed quotation mark after the character string ')" with this code:

Code Snippet

cmd = New SqlCommand("INSERT INTO PRODUCT VALUES ('" & Me.TextBox1.Text & _
            "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "','" & Me.ComboBox.Text & _
            "','" & Me.TextBox4.Text & "'"")", conn)


Do anyone know what's going wrong around Me.TextBox4.Text. Thanks.

Unclosed quotation mark after the character string ')

  

Hey!, I got a little problem in the web shop I am updating.

when a user wants to enter a item (say a city) like 's Hertogenbosch the page gives me the "unclosed quotation mark after character string" error.

Now i have been following multiple options  on the web, but since i am new to the whole asp.net and c# stuff i havent been able to get it to work.

Changing the whole thing to parameters is unfortunately not an option.

I hope anyone can help me with this.

 

Pierce

 

SqlCommand myCMD = new
 SqlCommand("insert into tmpCustomer (sessionid,firstname,namefix,surname,street,streetnumber,postalcode,city,nation,phonenumber,company,mail,payment,CustomerAlternateAddress,street2,streetnumber2,postalcode2,city2,CustomerOpmerking) values 
('"
+Session.SessionID+"','" +firstName.Value+"','" +nameFix.Value+"','" +surName.Value+"','" +street.Value+"','" +streetNumber.Value+

Unclosed Quotation Mark Error

  

 

Web Form (http://cforedu.com) post back reports: Unclosed quotation mark after the character string error

Message reads:


An Error Occurred: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''. Incorrect syntax near ''. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.Button1_Click(Object sender, EventArgs e) in http://server/Default.aspx.vb:line 17

 

Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected 

Unclosed Quotation Mark Error

  
Web Form post back reports: Unclosed quotation mark after the character string error Message reads: An Error Occurred: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''. Incorrect syntax near ''. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.Button1_Click(Object sender, EventArgs e) in http://server/Default.aspx.vb:line 17     Imports System.Data Imports System.Data.SqlClient Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As SqlConnection = Nothing Try conn = New SqlConnection("Data So

Msg 102, Level 15, State 1, Line 12 INCORRECT SYNTAX NEAR ')'

  
CREATE Table Item(
ItemID    numeric(18,2)  PRIMARY KEY,
VendorID   numeric(18,0)  NOT NULL,
ItemDescription  Char(50)   NULL,
PurchaseDate  DateTime   NOT NULL,
ItemCost   numeric(18,2)  NOT NULL,
ItemPrice   numeric(18,2)  NOT NULL,
 CONSTRAINT Item_FK FOREIGN KEY (VendorID)
  REFERENCES Vendor(VendorID)
  ON DELETE CASADE
  
);      <<<<HERE IS THE ERROR

Another ERROR Message Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'COLUMN'

  

Ok, I would like to ask you this if I may,

On another database I created a table named FICTION

and the table looks like this:

CREATE TABLE FICTION
 (BOOK_CODE CHAR(4) PRIMARY KEY,
 TITLE CHAR(40),
 PUBLISHER_CODE CHAR(3),
 PRICE DECIMAL(4,2) );

Now I am trying to change the data type in TITLE to CHAR(50)

ALTER

 

TABLE FICTION

MODIFY

 

COLUMN TITLE

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'MODIFY'

  
OK, TRYING TO UPDATE [MODIFY] AN EXISTING TABLE NONAPPLIANCE

HERE IS MY STATEMENT:

ALTER TABLE NONAPPLIANCE
MODIFY DESCRIPTION CHAR(30);

IT IS GIVING ME AN ERROR:

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'MODIFY'.

WHAT AM I DOING WRONG?

Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'WHERE'.

  

Hi,

Recently received a trace file from customer of sql server which shows some errors in SQL statement but the front-end application is working fine.

I see SET FMTONLY ON and SET FMTONLYOFF and an additional WHERE clause. The statement looks like:

SET FMTONLY ON SELECT PLANCODE.SYSCODE, PLANCODE.CODE, PLANCODE.NAAM

Msg 102, Level 15, State 1, Line 1 ,Incorrect syntax near '='

  

i am getting the error Msg 102, Level 15, State 1, Line 1 ,Incorrect syntax near '=' when i executing the query :-

insert

into author values(Ano=3,Author='Bannu',Addr='Delhi',Book='Hum-Tum')

Msg 156, Level 15, State 1, Line 7 Incorrect syntax near the keyword 'FROM'.

  

I am a student taking SQL classes and am having this error message with this SQL Script:

 

SELECT c.State, i.itemType,
        Cast(Year(o.orderDate) as Varchar) + N'-' +
        Cast((Month(o.orderDate) -1) / 3 + 1 as Varchar)
            as YearQuarter,
        Round((od.quantity * od.price)*(1-od.discount)
            as Sales
FROM Consumers c, Orders o, OrderLines od, inventory i
WHERE c.ConsumerId = o.ConsumerID and
        od.orderID = o.orderID and
        i.inventoryID = od.inventoryID;

 

any idea from that on what I am doing wrong? I'm thinking it's something simple.



Incorrect syntax near 'GO' error while running a sql script ?

  

I am using Visual Studio 2008

I have one Database A

now i want to create Database B just like Database A

I generated a script of Database A

and created fresh Database B

Now, when i try to run the generated script against Database B, i get this error, why ? how to fix it ?

sql error



For your information:

I have checked in my script it is:

SET ANSI_NULLS ON
GO

and i have also tried to save the sql script in notepad as: ANSI, UTF-8 and UNICODE

and then i copied from txt file to query but still doesn't work and getting the same error


and these are the option that i selected/used while creating my script:

s



Incorrect syntax near "("

  

Hi, below is a sub I wrote to run an SQLDataSource UpdateCommand. This is customized layer of a createUserWizard. I know I should probably have another table for the addt'l data and just FK the UserId...but I'd rather update the existing record and add the data to the existing row in the user (membership) table.

Can someone tell me what I'm doing wrong on this sub. The error is at the last line, "DataSource.Update()"

Thx.

 Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)
        FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, False)

        Dim UserNameTextBox As TextBox = DirectCast(CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"), TextBox)
        Dim DataSource As SqlDataSource = DirectCast(CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo"), SqlDataSource)

        Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
        Dim UserGUID As Object = User.ProviderUserKey

        DataSource.UpdateParameters.Add("UserId", UserGUID.ToString())
        DataSource.Update()

End Sub


 

 


Incorrect syntax near '<'

  
It was suggested that I use xmldocument.load to do a sql insert statement instead of BULK INSERT.  However when I run the Sub I am getting this error:  "Incorrect syntax near '<'.   "Here is my code, I have no clue what is causing this error, or how to fix it. Sub AO() Dim Z As String = Microsoft.VisualBasic.Format(Today.AddDays(-1), "MMddyyyy") Dim AO_Name As New String("\\Net\Import\AO-M_" & (Z) & ".xml") Console.WriteLine(AO_Name) Dim AOSQL As String Dim conn As New SqlConnection("Server=DEB\DEVDB;Database=MTrans;User Id=******;Password=**************************;") Dim cmd As New SqlCommand Dim x as New XMLDocument x.Load(AO_Namme) Dim xx As String xx=x.OuterXml AOSQL = "DECLARE @xml XML" + Environment.NewLine() + _ "SELECT @xml = " + xx + _ "Insert into AO (ASSET_OWNER_NAME,SCHEDULED_DATE,SETTLEMENT_CODE, INVOICE, OPERATING_DATE, DA_ADMIN, DA_ASM_REG, DA_ASM_SPIN)" + Environment.NewLine() + _ "SELECT ASSET_OWNER_NAME,SCHEDULED_DATE,CAST(SETTLEMENT_CODE AS smallint) AS SETTLEMENT_CODE, INVOICE, OPERATING_DATE, DA_ADMIN, DA_ASM_REG, DA_ASM_SPIN" + Environment.NewLine() + _ "FROM " + Environment.NewLine() + _ "(SELECT " + Environment.NewLine() + _ "summary.x.value('NAME[1]', 'VARCHAR(10)') AS ASSET_OWNER_NAME,summary.x.value('SCHEDULED_DAT

Incorrect syntax near '>'.

  
Hello everyone,I am getting a strange error message; Incorrect syntax near '>'.I made a listview with some dropdownmenu and selectboxes to select from untill the query shows in the listview.Now the query goes well and shows the first page of 4 rows as I wanted it.The pager shows 5 pages and if I a want to click on the next page I get this message. Incorrect syntax near '>'. 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: Incorrect syntax near '>'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [SqlException (0x80131904): Incorrect syntax near '>'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2030802 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009584 System.Data.SqlC

EXEC 17P_Comose will give incorrect syntax error. Because of numeric name

  
I am working with a sql server database with about 50 stored procedures. The database and stored procedureswere not created by me. The stored procedures all begin with a number in their name. Example: 17P_Comsetter The problem I am having is that if I try and execute the stored procedure at the command line in Query Analyzer,the query analyzer appears not to like that the stored procedure begins with a number. For example: If I try an run the stored procedure as follows: EXEC 17P_Comsetter Then I get the following error message:Msg 102, ..... Incorrect Syntax near '17' If I rename the stored procedure so that it does not begin with a number, then I do not get the error. The problemis that the company I am working at has a policy in place that stored procs must begin with a number.I am using SQL server 2005. Does anyone know why I am getting this error message?

LINQ to SQL "Incorrect syntax near the keyword 'WHERE'"

  

I am having a problem that creeps up over and over when using LINQ to SQL.  I am getting the error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'.

Now I have done a great deal of digging, and the only cause I can seem to find is when users are overriding the Equals() or GetHasCode() methods of the generated classes.  I am not overriding either.  I am getting this error on two different project with two different databases.  I have tried everything every post I have found suggests.  I have even scrapped my dbml file and re-created, all to no avail.

Anyone have any thoughts?  They would be greatly appreciated!


Thanks,
Ryan Sakry
Program Manager
Retail Information Technology Enterprises
1-888-267-RITE
rsakry@rite.us
http://www.rite.us
Categories: 
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