cannot insert character into MS Access

Wilfred

New member
Joined
Sep 24, 2007
Messages
1
Programming Experience
Beginner
Good Day,

I am new with VB.Net 2005. I am trying to write some data into ms access. I have quite alot of problems trying to do that. However I found that it is because I cannot send characters into ms access. my code as follow,

note: if I change the 'a' to 'anynumber', the update will be successful

------------------------------------------------------
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim str As String

Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Wilfred\Desktop\UnitProdn\UnitProdn.mdb;")
cn.Open()
str = "insert into [tbl_UnitProdn-ProductInformation] (LotNo,ModelName,Qty) values (" & "a" & "," & "2" & "," & "3" & ")"

cmd = New OleDbCommand(str, cn)
cmd.ExecuteNonQuery()
MessageBox.Show("DataEntered")

Catch ex As Exception
MessageBox.Show(ex.ToString())

End Try
cn.Close()

End Sub

End Class

------------------------------------------------------

pls help...:p
 
read the PQ link in my signature, then read the DW2 link(section: Creating a SImple Data App); it will tell you how to do your data access properly
 
Back
Top