Hi Roland
This is not done yet but I uploaded a new version where you should be able to get the connectionstring and sql statement back by ref.
The new file is here
http://www.sqlexcel.net/dload/temp/
I added in a new function to get the last connetion string.
Test function from VBA was
Public Function GetLastConnectionStringFromSQLExcel()
Dim oSQLExcel As Object
Set oSQLExcel = CreateObject("SqlExcel.Connect" )
GetLastConnectionStringFromSQLExcel = oSQLExcel.SQLExcel_GetLastConnectionString()
Set oSQLExcel = Nothing
End Function
Test Function for the passing byreg of sql and connection string was
Sub TestModifiedFuncion()
sConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=(LOCAL)"
sSQLStatement = "Select * From Categories"
Debug.Print "Original Connection String = " & sConnectionString
Debug.Print "Original SQL Statement = " & sSQLStatement
sSQLExcelStatement = GetSQLStatementFromSQLExcel(sConnectionString, sSQLStatement)
Debug.Print "New Connection String = " & sConnectionString
Debug.Print "New SQL Statement = " & sSQLStatement
End Sub
Sorry but this is not done yet.
I saw the same behaviour your described before - the "SQL Button" did not show when it should have - happened a few times but I do not know yet why and have no time to look tonight.
Also, the DLL will only work in Excel for now. I need several hours I think to get these two points sorted out. I am planning to do this on Friday/Saturday
Other point, is that the SQLExcel_LoadMainFormtoGetSQLStatement function is non standard now as it is returning parameters byref and also returning the SQL Statement as the return value for the function. I think this should be just retuning the boolean to indicate success or failure but cant change it now. Are you ok with this implementation ? True or False for function return and you get the refs for the connection string and SQL ?
Have to go now. If you have spare time it would be great if you could take a look.
Thanks and bye for now,
Al