Skip to main content

Posts

Showing posts from December, 2014

How To Handling Quote (') In VB.Net

hi there here i will share the way to handle quote (') during coding with VB.Net sometimes we will have data such as (MAT'L) that quote is definitely forbidden when we are use the data. create a function as below : Public Function Ganti(ByVal Kata As String) As String         Ganti = Replace(Kata, "'", "''")     End Function and here is this how you gonna use that function, read carefully Public Sub InsertDataDefect(ByVal Row As Integer)         Dim DefectName As String = dgvInputBMISDetail.Rows(Row).Cells("dgvInputBMISDetailDefectName").Value.ToString         Koneksi()         cmd = New SqlCommand("SELECT * FROM dbo.mstDEFECT WHERE (ActiveTo IS NULL) AND DefectName='" & Ganti(DefectName) & "'", Conn)         rd = cmd.ExecuteReader         rd.Read()         If rd.HasRows Then             With dgvInputBMISDetail                 .Rows(Row).Cells("dgvInputBMISDetailRecNoDefect").Value