I have a WindowsXPSP3 op system, on it a DelphiXE and InterbaseXE installed.
I created a database in IB and it works OK through the IBConsole and ISQL and connection testing also works through TCP/IP localhost:3050.
Now I try to access it from Delphi.
I did:
var AC:tADOConnection;
...
AC:=tADOConnection(Self);
AC.ConnectionString:=
AC.Open;
I tried all possible version I could google for the ConnectionString, but all generated an error. I used various Provider= versions, etc., but none works.
Could someone provide me with a simple working ConnectionString? Do I need to install any ADO driver or similar additionally?
Thanks,
Zsolt
There are two ways to easily create a valid connection string
a.1) Click on the small button in the object inspector right of the connection string property.
a.2) Create your connection, test it, press OK
or
b.1) Create an empty file e.g. 'TEST.UDL'. Use Notepad.EXE for example.
b.2) Double click on the file in the explorer. This will open the connection string editor
b.3) Create your connection, test it. Press OK
b.4) Your file now contains the connection string which you may copy&past in your application
Another benefit of the second method is that you can even use the file as a connection string. This makes life alot easier if you have to configure your connection from time to time (Just double click on the UDL if you have to change the connection properties). Here's how a valid connection string for a file looks like:
FILE NAME=<Full path to your UDL file>
Related
I use windows 7, 64-bit SP1, and TP Async V4.07 and have the following problem:
I have two Com ports, Com11, and Com18.
I add the following components to my form:
I open a Com port on ApdComPort2 (Com18) and it works without a problem. The ApdDataPacket2 detects the packet terminator and the result displayed is what is expected. Both Com11 and Com18 work fine.
Now if I open another Com port (Com11) with ApdComPort1 I get an Access violation:
The code that generates the error is this in the AdPacket module:
procedure TApdDataPacketManager.EnablePackets;
var
i : integer;
begin
for i := 0 to pred(PacketList.Count) do
with TApdDataPacket(PacketList[i]) do
if Enabled then
Enable;
end;
It is the PacketList.Count that seems to be the problem when it iterates through the list but I can’t catch why:
Note that ApdComPort2 works without problem with both Com11 and Com18.
If I remove the Apd2 components then Apd1 works as expected. The problems surface when I try to use two (or more) Apd components at the same time.
Does anybody have a suggestion or can recommend a component that works with more than one serial port simultaneously?
Some notes about the Turbo Power Async Professional components:
When using the Async components it is very important on how you add the components to the form. If you don’t does it in the right order and in the correct way it will not work if you use more than one serial port. You will actually get an access violation. For example, if you add the components below you have to do it in this way:
Add one ApdComPort to the form, it will become ApdComPort1
Now copy and paste this component to the form, it will become ApdComPort2
Add one ApdDataPacket component to the form, it will become ApdDataPacket1
Now copy and paste this component to the form, it will become ApdDataPacket2
Add one ApdSLController component to the form, it will become ApdSLController1
Now copy and paste this component to the form, it will become ApdSLController2
When doing it, as described above, it works to use two serial ports with ApdDatapacket. Now I don’t get any getting Access violations. I have tested it up to 4 ports and it works as well.
I am new to SSIS, here is the issue I am facing.
1) Created an OLEDB connection to connect to database. Storing the Connection String in SSIS variable and have added expression to Connection Manager to pick the connection string according to environment.
2) Have used Windows Authentication to connect to database, so that no need to provide user ID and Password. In development environment it worked perfectly fine. But when moved to testing environment, its failing with Error "SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "REGEDB" failed with error code 0xC0202009"
3) Using SQL Server Configuration to deploy the package. But getting error Failed to load at least one of the configuration entries for the package. Check configuration entries for "CBPSSIS" and previous warnings to see descriptions of which configuration failed.
Below is the Connection String
Data Source=abcd\ISQLQ02;Initial Catalog=DRIP;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;
COuld you please let me know how to set Password property? I tired in Script file but its not working. Thank you
ConnectionManager OldedbConn;
OldedbConn = Dts.Connections["QAREGE"]; Dts.Connections["QAREGE"].Properties["ServerName"].SetValue(OldedbConn, Dts.Variables["User::dbServerName"].Value); Dts.Connections["QAREGE"].Properties["InitialCatalog"].SetValue(OldedbConn, Dts.Variables["User::dbCatalog"].Value); Dts.Connections["QAREGE"].Properties["UserName"].SetValue(OldedbConn, Dts.Variables["User::dbUserID"].Value); Dts.Connections["QAREGE"].Properties["Password"].SetValue(OldedbConn, Dts.Variables["User::dbPwd"].Value);
Since you are using ssis-2008 you can create a ssis configFile with .dtsConfig format with xml configuration file type. Include all your Database connection string in the config file. So when you moved your ssis package to another server you just need to edit the config file and set your connection based on your target server.
I am trying to open and refresh an excel 2003 spreadsheet via ole. However I am getting the error "Add method of Workbooks class failed" with no further information.
The code works in unit tests, and works on 3 servers but fails with the error on our web server. It is being run from a service app running under the Local System Account.
The same version of excel is installed on all servers (2003 sp3). The file(s) in question all exist and are at the expected location.
There are no macros in the spreadsheets, but there are database queries. The spreadsheets can all be opened.
The calling code is
if VarIsEmpty(XLApp) then
begin
XLApp := CreateOleObject('Excel.Application');
try
XLApp.DisplayAlerts:= wdAlertsNone;
except
...
end;
XLApp.AutomationSecurity:= msoAutomationSecurityForceDisable;
end;
fullFileName:= ExpandReportFileName( partialFilename);
if not FileExists(fullFileName) then
raise Exception.Create('File not found: ' + fullFileName);
XLAPP.Workbooks.Add(fullFileName); << fail here
Any ideas on what else I can try?
I had been getting the same error for
xls.WorkBooks.Add(xlWBATWorksheet);
I changed that line to
xls.Application.Workbooks.Add;
Now it is working. You might try to get a Workbook first then try to call its methods.
Automating Office applications in a service is not supported.
While it is possible, it's very difficult, and you'll run into many problems, such as this one. It'll also be very slow.
You should look for a Delphi component that manipulates Excel files.
Depending on what you're trying to do, you might be able to use OLE DB instead.
Workbooks.Open might be the method you're looking for
Add creates a new empty workbook. If you supply a filename, that file is used as a template for the new file - see here
Open just opens the file as you would expect - see here
I ran into this error when I happened to have the Excel spreadsheet file selected in a Windows Explorer window, not open, just selected. When I deselect the file, I do not get the error.
What needs to be done to enable pooling in a Delphi 7 app? My connection string is:
Provider=SQLOLEDB.1;Initial Catalog=%s;Data Source=%s;Password=%s;User ID=%s;OLE Db Services=-1
I can tell that connection pooling is not being achieved by looking at the SQLServer:GeneralStatistics UserConnections performance counter - it fluctuates wildly when my application runs. With connection pooling I'd expect it to achieve a steady state. Also, I see that Logins/sec and Logouts/sec counters are both very high - if connection pooling were used Logouts/sec would be at or near zero.
In searching I found this article on resource pooling:
http://www.ddj.com/database/184416942
It suggests that "If you are working at the OLEDB SDK (or COM) level using ATL, you have to write some more code" (aside from adding OLE Db Services=-1 to the connection string) to get connection pooling:
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
dbinit.AddProperty(DBPROP_AUTH_USERID, "MyName);
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "MyServer);
dbinit.AddProperty(DBPROP_INIT_CATALOG, "MyDb );
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
dbinit.AddProperty(DBPROP_INIT_OLEDBSERVICES, (long)DBPROPVAL_OS_ENABLEALL);
HRESULT hr = db.OpenWithServiceComponents(_T("sqloledb"), &dbinit);
Unfortunately that code is Greek to me and I'm not sure how to translate that to Delphi (or if its even necessary).
I'm also careful not to change the connection string at all. Any suggestions on what else I might need to do to enable resource pooling?
You need to keep one instance of the connection open at all times...if it drops to zero, then ADO will re-establish the connection to authenticate the user.
You don't mention it, but are you using Delphi's ADO implementation (dbGo for Delphi 7, IIRC) for your data access? If so, are you connecting everything through the same TADOConnection? If so, it should be doing the pooling for your application (meaning that one running copy of your application is using one connection to the DB server).
lI am using the Data Application block for a majority of my data access, specifically using the SqlHelper class to call the ExecuteReader, ExecuteNonQuery, and like methods. Passing the connection string with each database call.
How can I modify this to enable connection to a MySQL database as well.
If you've got the Enterprise Library installed and already know how to connect to SQL Server databases, connecting to MySQL databases is not any harder.
One way to do it is to use ODBC. This is what I did:
Go to MySQL.com and download the latest MySQL ODBC connector. As I write this it's 5.1.5. I used the 64-bit version, as I have 64-bit Vista.
Install the ODBC Connector. I chose to use the no-installer version. I just unzipped it and ran Install.bat at an administrator's command prompt. The MSI version probably works fine, but I did it this way back when I installed the 3.51 connector.
Verify the installation by opening your ODBC control panel and checking the Drivers tab. You should see the MySQL ODBC 5.1 Driver listed there. It seems to even co-exist peacefully with the older 3.51 version if you already have that. Additionally it coexists peacefully with the .NET connector if that is installed too.
At this point you will be doing what you've done to connect to a SQL Server database. All you need to know is what to use for a connection string.
Here's what mine looks like:
Of course you can set "name" to whatever you want.
If this is your only database, you can set it up as the defaultDatabase like this:
Access your data in your code like you always do! Here's a plain text sql example:
public List<Contact> Contact_SelectAll()
{
List<Contact> contactList = new List<Contact>();
Database db = DatabaseFactory.CreateDatabase("MySqlDatabaseTest");
DbCommand dbCommand = db.GetSqlStringCommand("select * from Contact");
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
Contact contact = new Contact();
contact.ID = (int) dataReader["ContactID"];
client.FirstName = dataReader["ContactFName"].ToString();
client.LastName = dataReader["ContactLName"].ToString();
clientList.Add(client);
}
}
return clientList;
}
Another way to do it is to build and use a MySql provider. This guy did that.
I learned how to do this by adapting these instructions for connecting to Access.
Oh, and here are some more MySql Connection String samples.