Probably a wrong variable declaration.
Show us your code and the line where it gives the error
Property Get database12()
database12() = "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.path & "/Database/exceldata.xls"
End Property
VBA Code:Property Get database12() database12() = "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.path & "/Database/exceldata.xls" End Property
Sub adddata()
Dim connection1 As New ADODB.Connection
Dim data As New databaseclass
Dim sql As String
connection1.Open data.database12
sql = " insert into [sheet1$] (name, age, gender) values('shinjiang', 5, 'male')"
connection1.Execute sql
connection1.Close
Set connection1 = Nothing
End Sub