-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: pashish76
Message 9 in Discussion
hi Limson, The replace() does work here. have a look at the following code. I have
created a table in db1.mdb with a field called "textfield" and then i run the
following code it works, it inserts properly. Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim strConnect As String
Dim objConnect As OleDbConnection
#Region " Windows Form Designer generated code " Public Sub New()
MyBase.New() 'This call is required by the Windows Form Designer.
InitializeComponent() 'Add any initialization after the
InitializeComponent() call End Sub 'Form overrides dispose to clean up the
component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub 'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer 'NOTE: The following
procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 72)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 48)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False) End Sub #End Region Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
Public Function Conn()
strConnect = "provider=Microsoft.Jet.OLEDB.4.0;" & "data
source=C:\db1.mdb"
objConnect = New OleDbConnection(strConnect)
objConnect.Open() End Function Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Conn()
Dim teststr As String = "Hi it's a beautiful day."
teststr = Replace(teststr, "'", "''")
Dim sSQL As String = "INSERT INTO tb1(textfield) VALUES('" & teststr & "')"
Windows.Forms.MessageBox.Show(sSQL)
Dim objCmd As New OleDb.OleDbCommand(sSQL, objConnect) If
objConnect.State = ConnectionState.Open Then
Try objCmd.ExecuteNonQuery() Catch myException
As System.Exception
Windows.Forms.MessageBox.Show(myException.Message)
End Try
End If
objConnect.Close()
End Sub
End Class
regards Ashish P.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]