# Insert into table using macro in base [closed]

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I am attempting to write a simple program in base. Unfortunately, I need to insert a piece of information using a macro. However, the method that I used (below) for a select query did not work, and I cannot use the properties window to link the fields to the database (I need more control over the statement). Is there a way to do this?

The method I used is:

DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext") DataSource = DatabaseContext.getByName("Laptops")

If Not DataSource.IsPasswordRequired Then
Connection = DataSource.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
Connection = DataSource.ConnectWithCompletion(InteractionHandler)
End If