473,569 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error: Unclosed quotation mark after the character string..

4 New Member
Hye,

I need help to overcome the problem mention above.

My application needs user to key in their details, but when it comes to name some names has an apostrophe, somehow it's okay to save the data with apostrophe because through my observation, the system read from the database not the one that was keyed in by the user. For example, in the database already has a name "Alex" ... The one that just keyed in (edit) by the user " Alex'is" ... 1st edit, save and its okay, because it read "Alex" .. when you try to edit 2nd time, system read "Alex'is" ... and there pop up the error msg.

Type of error : Error #_2147217900 was generated by Microsoft OLE DB Provider fpr ODBC Driver [Microsoft][ODBC SQL Server Driver][SQL Server] (Unclosed quotation mark after the character string 'ABC1'")

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub CmdSave_Click()
  3.     If fnintCheckFields = 1 Then Exit Sub
  4.  
  5.     If Trim(cboRelationship.Text) = Op_Spouse Then
  6.         If gstrGender = Op_Female Then
  7.             cboGender.Text = Op_Male
  8.         Else
  9.             cboGender.Text = Op_Female
  10.         End If
  11.     End If
  12.     If Trim(cboRelationship.Text) = Op_Father Or Trim(cboRelationship.Text) = Op_Brother Then
  13.         cboGender.Text = Op_Male
  14.     End If
  15.     If Trim(cboRelationship.Text) = Op_Mother Or Trim(cboRelationship.Text) = Op_Sister Then
  16.         cboGender.Text = Op_Female
  17.     End If
  18.  
  19.     Select Case strRecMode
  20.         Case "ADD"
  21.             On Error GoTo ParaAdd1:
  22.  
  23.             Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
  24.             If CurrRs.RecordCount > 0 Then
  25.                 Call DispError(Msg_Exist)
  26.                 txtRelationship.SetFocus
  27.                 Exit Sub
  28.             End If
  29.  
  30.             CurrRs.AddNew
  31.             Call MoveScreenToDb
  32.             CurrRs.Update
  33.  
  34.             Call InitScreenFds
  35.             Call FieldEnable
  36.             txtRelationship.SetFocus
  37.  
  38.         Case "UPT"
  39.             On Error GoTo ParaUpt1:
  40.  
  41.             intCfmMsg = DispMsg(Msg_Save)
  42.             If intCfmMsg <> vbYes Then
  43.                 Call MoveDbToScreen
  44.                 Call FormatFields
  45.             Else
  46.                 Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
  47.                 If CurrRs.RecordCount > 0 And UCase(Trim(txtName)) <> UCase(Trim(txtName1)) Then
  48.                     Call DispError(Msg_Exist)
  49.                     txtName.SetFocus
  50.                     Exit Sub
  51.                 End If
  52.                 CurrRs.Close
  53.  
  54.                 '
  55.                 Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName1)))
  56.                 'Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
  57.  
  58.                 If CurrRs.RecordCount > 0 Then
  59.                     Call MoveScreenToDb
  60.                     CurrRs.Update
  61.                     Call UpdRelvNames
  62.                 End If
  63.             End If
  64.             txtName1 = ""
  65.             txtName.Enabled = True
  66.             txtRelationship.Enabled = True
  67.             cboRelationship.Enabled = True
  68.             Call Rtn_Enable(1)
  69.             txtEmp_No1.Enabled = True
  70.             cmdFindEmp.Enabled = True
  71.             CmdFind.SetFocus
  72.     End Select
  73.  
  74.     Exit Sub
  75.  
  76. ParaAdd1:
  77.     Me.MousePointer = 0
  78.     If Str(Err.Number) = "-2147217900" Then
  79.         Call DispError(Msg_Exist)
  80.         txtRelationship.SetFocus
  81.     Else
  82.         strErrMsg = "Error # " & Str(Err.Number) & " was generated by " _
  83.             & Err.Source & Chr(13) & Err.Description
  84.         MsgBox strErrMsg, vbCritical, "Error"
  85.     End If
  86.  
  87.     Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 2, 1, gintComp_Cd, gstrEmp_no)
  88.     Exit Sub
  89.  
  90. ParaUpt1:
  91.     strErrMsg = "Error # " & Str(Err.Number) & " was generated by " _
  92.             & Err.Source & Chr(13) & Err.Description
  93.     Me.MousePointer = 0
  94.     MsgBox strErrMsg, vbCritical, "Error"
  95.  
  96. End Sub
  97.  
  98.  
So, how would i solve this problem??

Thank you.
Apr 21 '11 #1
3 7465
VijaySofist
107 New Member
Hi,

In the Coding, you have to replace Single Quotes with Double Single Quotes for that Sring and the resulting string only, should be stored in the DB

Example
Expand|Select|Wrap|Line Numbers
  1. strResult=Replace(txtName.Text, "'","''")

Regards
Vijay.R
Apr 22 '11 #2
Aisya
4 New Member
thanks for the response...

I have tried the code but the error still pop up. Where should I put these line?? Since I have tried to put it inside the code below;

Expand|Select|Wrap|Line Numbers
  1. Private Function fnintGetRecord(ByVal strRelation As String, ByVal strName As String) As Integer
  2.     fnintGetRecord = 1
  3.  
  4.     Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 2, gintComp_Cd, gstrEmp_no, strRelation, Trim(strName))
  5.     strName = Replace(txtName.Text, "'", "''")
  6.     If CurrRs.RecordCount > 0 Then
  7.         fnintGetRecord = 0   '   Selected Record Was Found
  8.     Else
  9.         Call DispError(Msg_RecNotFound, "Employee's Family Details Record", 0)
  10.     End If
  11. End Function
  12.  
...and yet the error still pop up.

I replace the srtResult with strName since the system use strName to refer to the txtName. Am I on the right track?? :\

Should I put it somewhere in the previous code or in the code above??

p/s : i'm still new in VB6. Do help, thank you.
Apr 25 '11 #3
Aisya
4 New Member
I think I already found the right place to put the Replace statement...

Expand|Select|Wrap|Line Numbers
  1. Private Sub MoveScreenToDb()
  2.  
  3.     CurrRs("NAME") = Replace(txtName.Text, "'", "''")
  4.  
The error already gone but the problem now is the one that been registered to the db is "''" .. So when you want to edit the data for example, the name will appear with double quotes. ex, Alex''is

I tried to use the same method to the MoveDbToScreen which is display record from the database...but when I do that, the new edit doesn't record in the database anymore. Why is that? Is there anything that i missed?
Apr 25 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
38578
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
0
1300
by: Iham Sheen | last post by:
Hi, When I click at the Update button to commit changes in a MxDataGrid, I get the error message "Unclosed quotation mark ...." if there is a single quote in any of the columns. How can I work around this problem? Thanks. Iham
4
3770
by: | last post by:
Hi, How do I trim double quotation mark " in a string? Or, how do I match pattern if the string has double quotation mark already like "string"? Thanks in advance. Hugh
2
9284
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable called fileIds that is oftype varchar. I am putting in a comma separated string with ids (such...
9
2928
by: M P | last post by:
Hi! I am looking for a way that I can trap the single quotation mark. If an encoder uses single quotation mark on a textbox field, it always give me an error because I use single quotes on the SQL statement. Can you help trap this character not to produce error? Me
1
3814
by: izziy | last post by:
Our legacy DB has a bad column which stores a date value as char(8), it has a format like 'MMDDYYYY'. I am creating a report to report this particular date and also use this date to specify a range. I tried using this SELECT...
1
4666
by: SnehaAgrawal | last post by:
Hi I get the error "Syntax error converting datetime from character string "for the following sql statement in Stored proc. SET @dynamicSQL =N'SELECT CUSTID,SHCodeLink FROM AccountMaster where CONVERT(DATETIME,OPDATE,105) < = '''+CONVERT(DATETIME,@ACCYEAR,105) +''' And GLCode = '+@DIVGLCODE EXEC(@dynamicsql)
43
8528
by: dougancil | last post by:
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(SqlException exception, Boolean breakConnection) at...
1
1139
by: sagar shah | last post by:
Protected Sub BtnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnDelete.Click Dim feedbackId, Comm As String Dim GrdItm As DataGridItem For Each GrdItm In GrdFeedback.Items If CType(GrdItm.FindControl("ChkFeedbackDelete"), CheckBox).Checked = True Then feedbackId...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.