Hi, this code is my code to add a row to an excel file
It works fine as long as the variable Variable is a number. If i make it a string it doesnt work. Any ideas why?Code:Public Sub Add_Records() '========================================================================== ' Run an INSERT INTO command to add new records to the workbook. '========================================================================== Dim Variable As String Variable = "15000" Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1) conn1.Open() Dim cmd As New System.Data.OleDb.OleDbCommand() cmd.Connection = conn1 cmd.CommandText = "INSERT INTO [Sales$] (Reference, Customer, Quantity) values (" & Reference & "," & Variable & "," & Quantity & ")" cmd.ExecuteNonQuery() conn1.Close() End Sub
Thanks
Alex




Reply With Quote