Why won't this simple SQL statement INSERT a value?
- From: Blarneystone <BradIsaac@xxxxxxxxx>
- Date: Thu, 5 Jun 2008 11:42:27 -0700 (PDT)
Ok, I've got a simple access 97 db. named S_tracking.mdb
It has two tables
1- Jobs
2- Employees
I've set up the references:
Imports System.Data.OleDb
Imports System.IO
Imports System.data
I am simply trying to insert an employee number and name with the
following code and the code runs, but never puts anything in the
database!
'initializecomponent:
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=|DataDirectory|\S_tracking.mdb"
'end initializecomponent
cn = OleDbConnection1
cn.Open()
Dim DOrigin, Salesperson, JDescription, DTemplate, DInstall,
InvNum, Notes As String
DOrigin = dt_origin.Text
Dim SQL As String
SQL = "INSERT INTO Employees (EE_Number, Salesperson) VALUES
('5', 'Keith')"
Dim cmd As New System.Data.OleDb.OleDbCommand(SQL, cn)
cmd.CommandText = SQL
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.ToString)
End Try
When I use cn.close, to test if the database is even connecting, the
code errors saying must have an open connection. So I have the
connection, the data is going to the right places, but not being
accepted!
PS, my sql read statements are working...
What's wrong with the INSERTs?
Thanks,
Brad
.
- Follow-Ups:
- Re: Why won't this simple SQL statement INSERT a value?
- From: Scott M.
- Re: Why won't this simple SQL statement INSERT a value?
- Prev by Date: Re: Bitmap from Clipboard back to Clipboard as PNG?
- Next by Date: Re: Bitmap from Clipboard back to Clipboard as PNG?
- Previous by thread: .net 2.0 app setup demanding to install .net 3.5
- Next by thread: Re: Why won't this simple SQL statement INSERT a value?
- Index(es):
Relevant Pages
|