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'") -
-
Private Sub CmdSave_Click()
-
If fnintCheckFields = 1 Then Exit Sub
-
-
If Trim(cboRelationship.Text) = Op_Spouse Then
-
If gstrGender = Op_Female Then
-
cboGender.Text = Op_Male
-
Else
-
cboGender.Text = Op_Female
-
End If
-
End If
-
If Trim(cboRelationship.Text) = Op_Father Or Trim(cboRelationship.Text) = Op_Brother Then
-
cboGender.Text = Op_Male
-
End If
-
If Trim(cboRelationship.Text) = Op_Mother Or Trim(cboRelationship.Text) = Op_Sister Then
-
cboGender.Text = Op_Female
-
End If
-
-
Select Case strRecMode
-
Case "ADD"
-
On Error GoTo ParaAdd1:
-
-
Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
-
If CurrRs.RecordCount > 0 Then
-
Call DispError(Msg_Exist)
-
txtRelationship.SetFocus
-
Exit Sub
-
End If
-
-
CurrRs.AddNew
-
Call MoveScreenToDb
-
CurrRs.Update
-
-
Call InitScreenFds
-
Call FieldEnable
-
txtRelationship.SetFocus
-
-
Case "UPT"
-
On Error GoTo ParaUpt1:
-
-
intCfmMsg = DispMsg(Msg_Save)
-
If intCfmMsg <> vbYes Then
-
Call MoveDbToScreen
-
Call FormatFields
-
Else
-
Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
-
If CurrRs.RecordCount > 0 And UCase(Trim(txtName)) <> UCase(Trim(txtName1)) Then
-
Call DispError(Msg_Exist)
-
txtName.SetFocus
-
Exit Sub
-
End If
-
CurrRs.Close
-
-
'
-
Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName1)))
-
'Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 1, gintComp_Cd, gstrEmp_no, fnstrRelationship(cboRelationship.Text), fnstrAppendSingleQuote(Trim(txtName)))
-
-
If CurrRs.RecordCount > 0 Then
-
Call MoveScreenToDb
-
CurrRs.Update
-
Call UpdRelvNames
-
End If
-
End If
-
txtName1 = ""
-
txtName.Enabled = True
-
txtRelationship.Enabled = True
-
cboRelationship.Enabled = True
-
Call Rtn_Enable(1)
-
txtEmp_No1.Enabled = True
-
cmdFindEmp.Enabled = True
-
CmdFind.SetFocus
-
End Select
-
-
Exit Sub
-
-
ParaAdd1:
-
Me.MousePointer = 0
-
If Str(Err.Number) = "-2147217900" Then
-
Call DispError(Msg_Exist)
-
txtRelationship.SetFocus
-
Else
-
strErrMsg = "Error # " & Str(Err.Number) & " was generated by " _
-
& Err.Source & Chr(13) & Err.Description
-
MsgBox strErrMsg, vbCritical, "Error"
-
End If
-
-
Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 2, 1, gintComp_Cd, gstrEmp_no)
-
Exit Sub
-
-
ParaUpt1:
-
strErrMsg = "Error # " & Str(Err.Number) & " was generated by " _
-
& Err.Source & Chr(13) & Err.Description
-
Me.MousePointer = 0
-
MsgBox strErrMsg, vbCritical, "Error"
-
-
End Sub
-
-
So, how would i solve this problem??
Thank you.
3 7465
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 - strResult=Replace(txtName.Text, "'","''")
Regards
Vijay.R
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; -
Private Function fnintGetRecord(ByVal strRelation As String, ByVal strName As String) As Integer
-
fnintGetRecord = 1
-
-
Set CurrRs = VSHc.Open_HcFamily(CnnLoc, 3, 2, gintComp_Cd, gstrEmp_no, strRelation, Trim(strName))
-
strName = Replace(txtName.Text, "'", "''")
-
If CurrRs.RecordCount > 0 Then
-
fnintGetRecord = 0 ' Selected Record Was Found
-
Else
-
Call DispError(Msg_RecNotFound, "Employee's Family Details Record", 0)
-
End If
-
End Function
-
...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.
I think I already found the right place to put the Replace statement... -
Private Sub MoveScreenToDb()
-
-
CurrRs("NAME") = Replace(txtName.Text, "'", "''")
-
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?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Justin Wong |
last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords
(
@item varchar(50),
@last datetime
)
AS
SET NOCOUNT ON
|
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
|
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
|
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...
|
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
| |
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...
|
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)
|
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...
|
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...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |