all groups > sql server programming > may 2004 >
You're in the

sql server programming

group:

Add record to new workbook problem


Add record to new workbook problem Todd Huttenstine
5/2/2004 10:20:20 PM
sql server programming:
This is a new problem


Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Employee Database.mdb;" & _
"Extended Properties=Excel 8.0;"
' Create the SQL statement.
' szSQL = "INSERT INTO Employee Database " & "VALUES(ID, Employee Name,
Employe ID, Password);"
szSQL = "INSERT INTO Employee Database VALUES ('Hetland', 'Camilla',
'Hagabakka 24', 'Sandnes')"
' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing

' You 'll need to modify the connection string Data Source to point to
your
'Excel file and modify the SQL statement to fit your data.

Re: Add record to new workbook problem Steve Kass
5/3/2004 2:05:26 PM
Todd,

You don't indicate what the problem is, but

INSERT INTO Employee Database VALUES ...

is not valid syntax. If you have a table named Employee Database, you
need to write [Employee Database] or "Employee Database" because of the
space character. But I suspect that is not all that is wrong, because I
doubt that a file with extension .mdb is an Excel file.

Steve Kass
Drew University

[quoted text, click to view]
AddThis Social Bookmark Button