adodb

Finding The DSN To My Database?

假装没事ソ 提交于 2019-12-05 00:31:57
I have an SQL database and want to connect to it using VBA in order to support some legacy functionality. I'm using an ADODB connection and need to know what my database DSN is. How can I find this? I'm using SQL Server 2008, thanks! :D A DSN is an indirect way of referring to the database. You have to create them manually (or semi-automatically using a wizard of some kind). Go to ControlPanel->AdministrativeTools->DataSources (ODBC) to see if one has already been defined for the database to which you want to connect. But I think you might mean "connection string", not "DSN". There are many,

Excel VBA - connect to sql with a trusted connection (no uid/pwd)

时间秒杀一切 提交于 2019-12-04 19:29:56
问题 Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code. 回答1: I have this connectionstring in an Excel 2003 VBA project... "Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;" And it works for me! (I'm using ADODB) 回答2: Driver={SQL Native Client};server=servernamehere;database=dbnamehere;Trusted_Connection=yes; http

VBScript to correctly/re format a delimited text file?

大城市里の小女人 提交于 2019-12-04 18:01:28
Can someone help me reformat/correctly format a delimited text file using VBScript? I have a text file that is ^ delimited as below: AGREE^NAME^ADD1^ADD2^ADD3^ADD4^PCODE^BAL^ARREARS 00010004000051162^MISS JENNIFER GRAY ^123 FAKE STREET ^ ^TOWN ^COUNTY ^POSTCODE ^ 004978.00^ 000188.72 All of the data contains leading and trailing spaces that need to be removed. I only have VBScript available to do this. I have tried to use ADO GetStrings but it has yielded inconsistent results because of the leading and trailing spaces. Can anyone offer any suggestions or alternatives? Thanks Ekkehard.Horner

“Invalid procedure call or argument” error on “New ADODB.Connection” only if compiled on Windows 7

▼魔方 西西 提交于 2019-12-04 12:58:44
问题 I'm experiencing some problem when I compile some legacy apps on VB6 since I got a new development machine in windows 7. (my old one was on Windows XP.) If I compile the project on my XP machine, everything is fine. If I compile the same project on my Windows 7 machine, it still run fine one it, but if I try to run it on a XP machine, I got this error. Error Number : 5 Description : Invalid procedure call or argument Thanks to my error handler, I know that the line that throw this error is :

Using excels named range in a sql string in VBScript

陌路散爱 提交于 2019-12-04 10:39:02
I have searched on here and google but I still cannot solve my issue. I am trying to use an excel's named range equivalently in my .vbs file. The below works in VBA in excel but I cannot get it to work in a *.vbs file. ThisWorkbook.Sheets(1).Range("A1:B" & Range("B" & Rows.Count).End(xlUp).Row).Name = "DATA" strSql = "SELECT * FROM DATA" So, I have tried different variations of referencing to my named range DATA with no luck. This is what I have now: Set rng = ws.Range("A1:B2") rng = "DATA" strSql = "SELECT * FROM DATA" Some different variations involved: taking parameter ByVal, using rng

ADO Command running multiple SQL statements: can't get error message back: USE THE Connection.Errors collection

爱⌒轻易说出口 提交于 2019-12-04 10:14:28
I have some triggers on various tables that use raiserror to tell the user that he tried to do something bad. I would like to run several inserts and updates atomically, rolling back if one of the triggers says so. I was evil in a former life so I'm using Access VBA. If the first statement is at fault, I get a run time error in my VBA. However if the second or subsequent statement calls raiserror then I can't see any error message. SOLUTION: examine the connection.Errors collection. This is an Access 2007 ADP front-end and a SQL 2005 database. The VBA below is the bare minimum to show the

PHP and ADODB connection fail

微笑、不失礼 提交于 2019-12-04 05:57:46
问题 I have been tasked to migrate servers. This includes moving over apps I did not build, a couple of which have an ADODB.connection that I cannot seem to fix on the new servers (I only get blank screens). I have researched quite extensively ADODB.connection with PHP and cannot find a definite source. Most are related to VB Script, or even Excel documents. I even searched YouTube and the only thing I found wasn't even in English. I took some of the previous developer's code and created a test

ADODB RecordSet as Access Report RecordSource

柔情痞子 提交于 2019-12-04 04:46:25
I have a simple form, a query and a report in Access 2003. I have to manipulate the results from the query in a recordset using VBA and then pass it on to the report as its RecordSource. If I declare the recordset as RecordSet and use its Name property as the RecordSource of the report then it is working. However, because I need to edit the recordset, I though it would be easier to use an ADODB RecordSet as below. The records set is declared as Dim rs As ADODB.RecordSet in a global module. The rest of the code is; Dim db As Database Set db = CurrentDb Dim con As ADODB.Connection Set con =

Calling SQL Stored Procedure with Output Parameter in VBScript

萝らか妹 提交于 2019-12-04 01:09:37
问题 I've written a VBScript function to call a stored procedure. In the past, I've written a number of functions calling stored procedures with input parameters, but in this instance, I need to work with an Output parameter. In another application, I call the exact same stored procedure using the Entity Framework, so the stored procedure is fine. Here's my code: Function checkAccess(userid,link) isAllowed = false set cmd = Server.CreateObject("ADODB.Command") cmd.CommandText = "Check_Permission"

XML output parameters with ADODB in ASP Classic

。_饼干妹妹 提交于 2019-12-03 21:31:56
I found this error looking for a solution to a problem of retrieving XML at ASP classic: Declaring XML output parameters with ADODB in ASP Classic I have the same error working with Classic ASP and SQL Server 2003. I used to work with a .dll in VB6, where I could get the XML code. But now I need to do it from SQL direct to ASP. Did you manage to solve it? My code in classic ASP so far is: set objCommandoOP = Server.CreateObject("ADODB.Command") Set objCommandoOP.ActiveConnection = objConexion objCommandoOP.CommandType = adcmdStoredProc objCommandoOP.CommandText="spProducesXML" set ParamEnt =