xavierh Posted June 7, 2011 Share Posted June 7, 2011 The database file exists, and I can connect to it and read its data from C#. But I also need to access the data from autoit. I have tried variants of the provider string below, but the connection just fails to open. Dim $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Open("Provider=Microsoft.SQLSERVER.OLEDB.CE.3.5;Data Source=C:\Auto\tests.sdf;Password=test") Has anyone managed to connect to a sql ce database? Thanks, Xavier Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 9, 2011 Share Posted June 9, 2011 Isn't that provider a .NET library? AutoIt can't use that. Do you have any examples of connection strings for SQL CE that work with ADODB in VBScript or some other non-.NET source? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
xavierh Posted June 10, 2011 Author Share Posted June 10, 2011 I finally got it to work as long as the db is not encrypted (ie it was not created with a password). If you add a password to the db when created from C#, both vbs and autoIT fail to connect.Here are working samplesvbscript:set oCon = createobject("ADODB.Connection")set oRS = createobject("ADODB.Recordset")oCon.Open "Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=C:\Auto\PPDTM\PPDTM\PPDTM\bin\Debug\tests.sdf"oRS.CursorLocation = 3 'adUseClientoRS.Open "select * from PSMWinPrinters", oCon, 3, 3 'adOpenStatic, adLockOptimisticmsgbox oRS.recordcount & " records"msgbox oRS.Fields(1).ValueoRS.CloseoCon.CloseAutoIT script:Dim $sqlCon = ObjCreate("ADODB.Connection")$sqlCon.Open("Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source=C:\Auto\PPDTM\PPDTM\PPDTM\bin\Debug\tests.sdf")Dim $oRS = ObjCreate ( "ADODB.Recordset" )$oRS.open ( "select * from PSMWinPrinters", $sqlCon, 1, 1, 1 ) ;$adOpenKeyset, $adLockOptimistic=3, $adCmdText )msgbox(0,"", $oRS.recordcount & " records") Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 10, 2011 Share Posted June 10, 2011 Thanks for reporting your resolution. Cheers! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now