All my oracle varchar2 data returns empty(EmptyStr) using an firedac connection + firedacQuery. I tryed an ADO connection on same database and all strings appear normally.
Can anyone explain? Im using delphi XE5 + oracle 11g, database charset is WE8ISO8859P15.
I was able to resolve my problem by updating the oci driver.
Related
Please do me a favor, I want to maintain all the stored procedures in one database, let's say SP_Dbase.
I plan this scheme, user application determine dbase_xyz and will go to SP_stored_procedure in SP_Dbase and then retrieve or edit data of dbase_xyz.
Since command Use dbasename does not work in a stored procedure, I have big difficulty.
I don't intend to write down all the procedure as an execute command as follows :
Set #cmd = 'select .... from ' + #DB + '.dbo.tablename'
EXEC(#cmd)
Anyone could help me ?
Note: All databases have same structure and exist in one SQL Server 2008 R2 instance.
Thanks
When I am trying establish a ODBC connection in cognos connect to vertica database, I am getting “Unicode converter buffer over flow”. Please guide me inthis issue.
Thanks,
Indu
Try adding DriverUnicodeType=1 into odbc.ini for your vertica dsn entry.
This will cause the driver to use utf-16 instead of utf-8 it uses by default.
A sample ODBC setup for Datastage: http://www-01.ibm.com/support/docview.wss?uid=swg21587289
I am trying to post a date to a dateTime column in a SQL Server 2008 R2 database, but I have run into many problems that I don't know what are the causes.
First, I used this code but I got the error:cannot convert string to date.
ADOOF.SQL.Text:='UPDATE OFTab SET CA='''+ CA.Text + ''', demandeClient=''' + DateTimeToStr(demandeClient.DateTime) + ''' WHERE ID='''+ ADOOF.FieldByName('ID') + '''';
ADOOF.ExecSQL;
Second, I have used parameters:
ADOOF.SQL.Text:='UPDATE OFTab SET CA='''+ CA.Text + ''', demandeClient=:demande_client WHERE ID='''+ ADOOF.FieldByName('ID') + '''';
ADOOF.Parameters.ParamByName('demande_client').Value:= demandeClient.Date;
ADOOF.ExecSQL;
But I got the error: Parameter (demande_client) not found.
I googled this problem and I found a suggestion by Embarcadero saying that the parametres sould be created before calling the ADOQuery like this:
ADOOF.SQL.Text:='UPDATE OFTab SET CA='''+ CA.Text + ''', demandeClient=:demande_client WHERE ID='''+ ADOOF.FieldByName('ID') + '''';
ADOOF.Parameters.ParseSQL(ADOOF.SQL.Text, True);
ADOOF.Parameters.ParamByName('demande_client').Value:= demandeClient.Date;
ADOOF.ExecSQL;
Finely I removed the connection Persist Security Info but always the same problem.
Please, any suggestions.
INFO: I am using MICROSOFT OLE DB Provider For SQL Server.
in your first example use
FormatDateTime('YYYYMMDD hhmmss',demandeClient.DateTime)
instead of
DateTimeToStr(demandeClient.DateTime)
This is because DateTimeToStr without formatsettings uses your localized machine settings and your database just might or might not like the format. Using FormatDateTime also gets rid of ambiguities: consider 01/02/03, for some people on the world this is january 2nd 2003 but for others 1st of februari 2003 and even some will say 2001, februari 3rd. YYYYMMDD is universal. 20030201 is always 1st of februari 2003.
It can depend on how you connect to your DB (drivers).
You can try to explicit that you are using a Date:
ADOOF.Parameters.ParamByName('demande_client').DataType:= ftDateTime;
ADOOF.Parameters.ParamByName('demande_client').AsDateTime:= demandeClient.Date;
I will strongly suggest to use SQL Native Client 11 when you are working with SQL Server 2008 R2. New SQL Server 2008 data types (including DATE, TIME, DATETIME2, and DATETIMEOFFSET) are not supported by the SQL Server 2000 OLEDB provider.
Your second code sample should work. Check that you have TADOQuery.ParamCheck = True.
Embarcadero® Delphi® 2010 Version 14.0.3593.25826
We are attempting to move a database from SQL Server 2000 to SQL Server 2008. I have a TClientDataSet that is loaded with a SELECT that includes a computed column, i.e., "SELECT Comp_Col = Column1 + ' ' + Column2...".
Running against an SQL Server 2000 database, I can modify the value of the column in the TClientDataSet using the following code:
ClientDataSet1.Edit();
ClientDataSet1.FieldByName('Comp_Col').ReadOnly := false;
ClientDataSet1.FieldByName('Comp_Col').Value := 'MODIFIED';
ClientDataSet1.FieldByName('Comp_Col'').ReadOnly := true;
ClientDataSet1.Post(); // <-- EXCEPTION in 2008
Running against an SQL Server 2008 database, though, I get a "Trying to modify read-only field" error when executing .Post().
I have tried also setting .ProviderFlags = '[]' for the column (in addition to .ReadOnly = false) in the above code, but still get the error. I have also tried setting .ReadOnly = false and .ProviderFlags = '[]' at design-time via the IDE, but this does not help either.
Anybody know how to set a computed column in a TClientDataSet when running against an SQL Server 2008 database?
Thanks!
* UPDATE: ANSWERED *
I discovered the problem--or at least a workaround...
I WAS setting .ReadOnly = false for the column in the TClientDataSet object. This worked with SQL Server 2000 but not with SQL Server 2008.
If I set .ReadOnly = false in for the column instead in the TADOQuery object that is serving as the provider, then I am able to set the value of the computed column in the TClientDataSet object at run-time.
Not ideal for me since this was implemented in a generic function for TClientDataSet objects (that didn't anything about the provider), but it will have to do for now.
I discovered the problem--or at least a workaround . . .
I WAS setting .ReadOnly = false for the column in the TClientDataSet object. This worked with SQL Server 2000 but not with SQL Server 2008.
If I set .ReadOnly = false for the column instead in the TADOQuery object that is serving as the provider, then I am able to set the value of the computed column in the TClientDataSet object at run-time.
Not ideal for me since this was implemented in a generic function for TClientDataSet objects (that didn't anything about the provider), but it will have to do for now.
My experience shows that the creation of ClientDataSet fields by calling TClientDataSet.CreaeteDataSet initially without ReadOnly flags solves the problem. After opening ClientDataSet fields' ReadOnly flags can be returned to their seats for the proper functioning of data-aware controls.
Dim NorthWindOledbConnection As String = "Provider=SQLOLEDB;DataSOurce=SARAN-PC\SQLEXPRESS;Integrated Security=ssp1;InitialCatalog=Sara"
Dim rs As New ADODB.Recordset()
rs.Open("select * from SecUserPassword", NorthWindOledbConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)
i tried to run this above code in visual studio 2008 - it shows the following error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done"
Firstly, don't use ADO in VB.NET. Use ADO.NET.
Other than that, create a proper Connection object instead of passing around a string.
And fix your connection string. It's SSPI, not SSP1. And it's Data Source, not DataSOurce. And it's Initial Catalog, not InitialCatalog.
You are using a very very very old way to access a Database that has been used with Visual Basic 6 and older.
Check to use ADO.NET instead of old ADO. For example you can use this code that is "similar" to the code you are using (but is not the best way to access the data on VS2008)
OleDbConnection con= New OleDbConnection( **Your Connection String** )
con.Open()
Dim command As OleDbCommand = New OleDbCommand("select * from SecUserPassword", con)
sqlCommand .CommandType = CommandType.Text
Dim reader As OleDbDataReader = TheCommand.ExecuteReader()
While reader.Read()
System.Console.Write(reader(** Your Table Field Name** ).ToString())
End While
con.Close()
To view how to create a correct connection String see the site http://www.connectionstrings.com/
If you want to access to an SQL Server database also you can use the SQLClient namespace instead the OleDb. For example System.Data.SqlClient.SqlConnection instead the OleDbConnection to provide better performance for SQL Server
The link below is an article that gives a great breakdown of the 6 scenarios this error message can occur:
Scenario 1 - Error occurs when trying to insert data into a database
Scenario 2 - Error occurs when trying to open an ADO connection
Scenario 3 - Error occurs inserting data into Access, where a fieldname has a space
Scenario 4 - Error occurs inserting data into Access, when using adLockBatchOptimistic
Scenario 5 - Error occurs inserting data into Access, when using Jet.OLEDB.3.51 or ODBC driver (not Jet.OLEDB.4.0)
Scenario 6 - Error occurs when using a Command object and Parameters
http://www.adopenstatic.com/faq/80040e21.asp
Hope it may help others that may be facing the same issue.