R
rudy
I'm trying to insert text values into a table in a MSAccess DB
the values are stored in string variables
Imports System.Data.OleDb ....
Dim name As String
Dim position As String
Dim site As String
Dim MDBConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = C:\Test.mdb")
Dim cmd As New OleDbCommand("CREATE TABLE tblTest(site string,namex
string, positionx string)", MDBConn)
MDBConn.Open()
cmd.ExecuteNonQuery()
cmd.Connection = MDBConn
site = 'testsite'
name = 'testname'
position = 'testposition'
cmd.CommandText = "insert into tblTest (site, namex, positionx) VALUES
(site, name, position)"
cmd.ExecuteNonQuery()
which generates an error but if I use
cmd.CommandText = "insert into tblTest (site, namex, positionx) VALUES
('site', 'name', 'position')"
of course it puts the variable names into the table
any help would be appreciated
the values are stored in string variables
Imports System.Data.OleDb ....
Dim name As String
Dim position As String
Dim site As String
Dim MDBConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = C:\Test.mdb")
Dim cmd As New OleDbCommand("CREATE TABLE tblTest(site string,namex
string, positionx string)", MDBConn)
MDBConn.Open()
cmd.ExecuteNonQuery()
cmd.Connection = MDBConn
site = 'testsite'
name = 'testname'
position = 'testposition'
cmd.CommandText = "insert into tblTest (site, namex, positionx) VALUES
(site, name, position)"
cmd.ExecuteNonQuery()
which generates an error but if I use
cmd.CommandText = "insert into tblTest (site, namex, positionx) VALUES
('site', 'name', 'position')"
of course it puts the variable names into the table
any help would be appreciated