Type mismatch for field 'xxx', expecting: WideString actual: String

Development Enviornment

Delphi XE2
oci.dll 11.2.0.1
sqlncli10.dll 2007.100.2531.0 
MS SQL Server 2000, 2005, 2008. Collated Arabic_CI_AS 
Oracle 11g NLS Characterset WE8ISO8859P1 
Application using datasnap/dbexpress driver
Windows XP

Problem Area

We have an application that we are converting to runs on both Oracle and MS SQL Server. 

The Oracle driver brings back Varchar2 as TWideStringField. The SQL Server driver brings back Varchars as TStringField. 

This becomes a problem for our persistent fields. The error we receive is "Type mismatch for field 'xxx', expecting: WideString actual: String." 

I would like to know if we are missing something. 

Steps to reproduct 
This can easily be reproduced by dropping a TSQLConnection and TSQLQuery component on a form. The TSQLQuery selects a table with a simple varchar/varchar2 column. Then you create a persistent field for that column and repeat for each database type. 

I would like to know How we can fix this problem
0
Prakash
11/20/2012 11:42:41 AM
embarcadero.delphi.multi-tier 396 articles. 0 followers. Follow

1 Replies
2857 Views

Similar Articles

[PageSpeed] 59

Am 20.11.2012 12:42, schrieb Prakash Shirodkar:
> The Oracle driver brings back Varchar2 as TWideStringField. The SQL Server driver brings back Varchars as TStringField.
>

You cannot use different databases with persistent fields when the field 
types are different between those databases. String fields and 
WideString fields are different. You can try to use NVARCHAR fields with 
SQL Server.


-- 
Uwe Raabe
Embarcadero MVP
Certified Delphi Master Developer
Uwe's Blog: The Art of Delphi Programming <http://www.uweraabe.de/>
0
Uwe
11/20/2012 1:23:03 PM
Reply:

Similar Artilces:

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

Cast from type 'Field' to type 'String' is not valid
I am getting the error msg on this code...Response.Write(objRSCount("iCount") & " records for " & frmDispOption & " '" & frmText & "'. They are listed below:")I have tried converting the frmDispOption and frmText variables to strings using CStr after getting the values from the DB but still get the same msg.  Can someone please help me out, thanks.David. What is "objRSCount"? ie what type is it? You also need to make sure that objRSCount("iCount") is string.ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog||Dub@i.net Hi, i f...

Type Mismatch field 'EventDate' expecting: Date actial:Widestring
Hi In an SQL database I have a field with a data type of ‘Date’. In FireDAC I have this field also setup as a TDateField. I have used LiveBindings to connect a TEdit to the ‘EventDate’ data field, which is where I imagine the problem comes from. What I can’t understand is why it works fine on my local copy of SQL and the ‘live’ SQL Server from my own laptop (which is using Delphi XE5) but gives an error message when run on a clients PC. On a Users PC I get an error message ‘Exception eDatabaseError in module …. At ….., fdqCalendar: Type mismatch for field ‘EventDate’, expecting: Date actua...

Type mismatch for field 'FieldName', expecting: AutoInc actual: LongWord
Hi, I get this error message with AnyDAC (FireDac) components. To show my error, I reduce my mysql table to the minimum. I have two MySQL table who contains many fields of type (string, integer, datetime etc...). The first table named "ReportLog" contain three fields: 'ID' (INTEGER AutoIncrement) 'RptDateTime' (DATETIME) 'fk_OperatorLog' (INTEGER) The second table named "OperatorLog" contain two fields: 'OperId' (INTEGER AutoIncrement) 'DKeyId' (VARCHAR) I put a TFDQuery (na...

value of type 'XXX' cannot be converted to type 'XXX'
 I've had this issue with VS2008 lately that is driving me crazy.  I have a website where I built a class that does all my Web Service interaction.  This class returns instances of Web Service proxies, or list of the same.  In my web page I'll create a temporary variable (Dim - I'm using VB) with the same type that my service class is going to return.  When I assign my variable to the return of the method, I'm getting a message similar to the following"Value of type 'Namespace.Foo' cannot be converted to type 'Namespace.Foo'. ...

Operator '==' cannot be applied to operands of type 'string[]' and 'string'
Hi, I have the following C# code and the line - " if(a == "Document Library") break; " - is giving me the error - Operator '==' cannot be applied to operands of type 'string[]' and 'string' I am not very familar with c# and would appreciate any help as to how to get around this. I have checked google but can't see anything covering this. Cheers for all help... string [] a; try { currentFolder = currentFolder.Replace("%2f","/"); currentFolder = currentFolder.Replace("%20"," "); a = curre...

E2094 'operator+' not implemented in type 'XXX' for arguments of type 'int'
Okay I have a problem; I am trying to extend a string class that I wrote for a friend so I can use it another project I am working on. I have an error that makes absolutely no sense. Here is the code for the copy constructor: String(const String &str) // for copying into a new string object { Size = str.Size; Data = new char[Size+1]; for (int i = 0; i<Size; i++) Data[i] = str[i]; // recieving the following error on the above line: [BCC32 Error] Mystring.h(33): // E2094 'operator+' not implemented in type 'String' for arguments of typ...

Cannot implicitly convert type 'string[]' to 'string'
Hello Everyone, i have file name "sample.txt". it contains customer order information like order id, cust id, and the order information. the below code is in c# . it has ReadButton which reads the info from the file. now my problem is how get the string[] CustResult value to be shown in Label box.protected void ReadButton_Click(object sender, EventArgs e) {  StreamReader Sr = new StreamReader(Server.MapPath(".") + "/confirm/sample.txt"); String ReadContents = Sr.ReadToEnd();char Delimiter = '\n'; char TabDelimiter = '...

Occaisonal Build problems (type 'xxx' exists in both 'yyy.dll' and 'xxx.dll')?
Hello: Been working with Express for about 2 months now -- and it generally works fine -- but I occaisonally get this error message when I rebuild projects to rerun it: ------ Rebuild All started: Project: http://localhost/TestIV/, Configuration: Debug .NET ------ Build Web Beginning D:\DEV\DEV_NET\CS\SITES\TestIV\portal.aspx(9,31): error CS0433: The type 'ASP.Portal' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\2bc5e680\fdf16dd9\f3iai7un.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\...

Cast from type 'DBNull' to type 'String' is not valid.
Ok, that is the error... "Cast from type 'DBNull' to type 'String' is not valid. " I am filling a DataSet from the db and some fields are empty. Reading from it and placing the info into a label. Code below.... Sub getProductInfo() Dim DSprod2 As New DataSet() Dim MyCommand As OleDbDataAdapter sql = "Select * from tblProducts Where fldNum = " & intfldNum MyCommand = New OleDbDataAdapter(sql, conn) MyCommand.Fill(DSprod2, "tblProducts") lblProd.Text = DSprod2.Tables("...

Cast from type 'ListItem' to type 'String' is not valid
Hi I am getting this error message when I try to view the sql of my insert command in the Oldbcommand1.commandtext statement. can somebody help me. The insert statement is as follows: (Most of the seesions are strings and the others come from a list item value (listitem.selecteditem.value) OleDbCommand1.CommandText = "insert into wlc_mvts values ('" & trs & "','" & Session("payment_mode") & "','" & Session("freight") _ & "','" & Session("red_clause") & "','&...

Conversion from type 'DBNull' to type 'String' is not valid
I get this error when I try to add an event:Conversion from type 'DBNull' to type 'String' is not validI've been able to add events before, but all of the sudden I'm getting the error...Here is the output of the error:Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid.Source Error: Line 115: </h3> Line 116: <p> Line 117: <asp:Label ID="descriptionLabel" runat="server" Text='<%# truncate(CStr(Eval("description"))) %>' />...

Conversion from type 'DBNull' to type 'String' is not valid.
On line 65 of Events_Calendar.aspx- <div style="padding: 3px;"> <asp:HyperLink ID="HyperLink1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%# "Events_view.aspx?Eventid=" &CStr( Eval("ID"))%>' ToolTip='<%# truncate(CStr(Eval("description"))) %>' /></div> The debugger tells me "InvalidCastException unhandled by user code" I found out that the data entry form for events allows the user to leave the description field empty.  So this translates to NULL in the SQL Server 2005 database.  the NULL value in the description field...

Cast from type 'Byte()' to type 'String' is not valid.
Hello - I need to use the id from one query to throw into another query. Thing is the id in the first database is in the format: 0x00000000000227F1 but when it shows in a data grid. it just shows: Byte[] Array I need to get the value of Byte[] Array as a string in the format: 0x00000000000227F1 When I query it in query analyzer, it shows as: 0x00000000000227F1 but, like I say, in my data grid , it just shows as Byte[] Array So when I try to use it in a query I get the error: Cast from type 'Byte()' to type 'String' is not valid. Any ideas? Thanks ...

Web resources about - Type mismatch for field 'xxx', expecting: WideString actual: String - embarcadero.delphi.multi-tier

Resources last updated: 1/15/2016 3:08:59 PM