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
Statement = Connection.prepareStatement("SELECT ""username"",""password"" FROM ""Users"" WHERE ""username"" LIKE ? AND ""password"" = ?;")
Statement.setString(1,Uname)
Statement.setString(2,Pwd)
ResultSet = Statement.executeQuery()