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


Top 5 Contributors of the Month
david stephan
Asad Ali
Fauzul Azmi
Post New Web Links

Unclosed quotation mark after the character string ')

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :Sql Server
 
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.



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 ')

  

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+

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

  

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

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

WebMatrix conversion failed when converting from a character string to uniqueidentifier?

  

I am trying to retrieve xml from a small function in my .cshtml page. Its throwing me an error. This however, runs fine in a console/form environment.

It takes 3 parameters and 1 exception.

myDll.GetXML(year, username, uniqueidentifier, out ex);

When I run this page I get the error, "Conversion failed when converting from a character string to uniqueidentifier."

Or a stack of.

System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.

   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()

   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBeha

How to read string end with question mark in regular expression?

  
Hello, I'm facing problem when I read string which is ended by question mark. I use in my code as the following. \"?(?<myfield>[^\"]?.*[^\"?]?)\"? If string is ended by question mark, it's not working. Please help me to solve my problem. Thanks. Co Coe

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

Problem with quotation mark that is not resolved using \"

  

Hi everyone,

I have an aspx page that conatain:

<asp:SqlDataSource ID="dsName" runat="server"

ConnectionString="<%$ ConnectionStrings:myConnectionString %>

SelectCommand="SELECT t1.ID, t2.desc FROM table1 t1 JOIN \"10.10.10.10\".dbname.schemaName.table2 t2 ON t1.ID = t2.ID">


I can already see in visual studio that the quotation mark are not reacting as they should.

and when trying to run it I get: "The server tag is not well formed."

If I remove the \" from the string or try to replace " with '  I get incorrect syntax for the sql query.


How can i use place quotation mark in that string?



Best Method to remove special character from string

  
I am trying to remove the special characters from a string that was entered by the user.  I am not sure the best method to do this.  i can get a foreach of all the characters but what do i check it against?
Christian - developer

SQL error: Conversion failed when converting date and/or time from character string.

  
I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 
JR

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
set

Conversion failed when converting datetime from character string. SQL Server @StartDate as datetime

  

Hi,

Can you please help me on this?

When I try to pass my parameter it doesn't work. See below is my code :

 

declare @SQL Varchar(4000)

declare @CRM_FilteredAppointment nvarchar(2000)

declare @CRM_FilteredSystemUser nvarchar(2000)

declare @StartDate datetime

declare @EndDate datetime





set @CRM_FilteredSystemUser = 'Select * from FilteredSystemUser'

set @StartDate = '20080101'

set @EndDate = '20100101'



set @CRM_FilteredAppointment = 'SELECT activityid, participationtypemask 

FROM FilteredAppointment 

WHERE FilteredAppointment.eu_calltype = 2

AND FilteredAppointment.statecode = 1

AND FilteredAppointment.scheduledend >= DateAdd( month, -1, GetD

Conversion failed when converting from a character string to uniqueidentifier

  

Hi all,

 

I am trying to match a username to a userid which are in 2 different sql tables. Here is my select statement:

SELECT     aspnet_Users.UserName
FROM         aspnet_Users INNER JOIN
                      aspnet_starterkits_Projects ON aspnet_Users.UserName = aspnet_starterkits_Projects.ProjectManagerId

When I run this i get an error message: "Conversion failed when converting from a character string to uniqueidentifier"

Is there anyway around this? Or a different select statement etc?

 

Thanks!


use question mark in search representing exactly one character - possible?

  

Hi,

Is there way to use the question mark ? in MS SQL Search Expression? Like so:

SELECT [Name] FROM [dbo].[Users] WHERE [Name] = "M?yers"

The ? stands for exactly 1 character. I tried LIKE

SELECT [Name] FROM [dbo].[Users] WHERE [Name] LIKE "M%yers"

but the % represents 0 or more characters!

Thanx for help,

S.


Replacing last comma in string with different character

  

Hi i have a string, and i want to replace the last comma with something else. For instance this is my string;


"Monday, December 6, 9:00 PM"


How do i replace that last comma so it can look like this;


"Monday, December 6 2010 9:00 PM"


Program to find first non repetable character in a string without using any buitin function?

  

Program to find first non repetable character in a string without using any buitin function?


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