Advertisement

02.13.2008 at 04:33AM PST, ID: 23159372
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Cast Exceptions when Attempting to Read Visual Foxpro Table in VB .NET

I'm using OLEDB in VB .NET to read through a Visual Foxpro Database.

I'm using commands like: oleDbReader.GetInt32(1) and oleDbReader.GetString(2)
to obtain columns from the VFP tables which works fine, but some of my columns are VFP types of Numeric(11,&) and Numeric(11,1).
I can't seem to find a command that ill convert these data types in VB .NET.
If I do ? oleDbReader.GetDataTypeName(?) it returns "DBTYPE_NUMERIC"
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: VFPSQLDeveloper
Solution Provided By: VBRocks
Participating Experts: 2
Solution Grade: A
Views: 4
Translate:
Loading Advertisement...
02.13.2008 at 07:12AM PST, ID: 20884780

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 07:14AM PST, ID: 20884807

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 07:37AM PST, ID: 20885037

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 07:42AM PST, ID: 20885090

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 08:02AM PST, ID: 20885273

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 08:06AM PST, ID: 20885307

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 08:11AM PST, ID: 20885364

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.13.2008 at 01:53PM PST, ID: 20888670

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.14.2008 at 07:36AM PST, ID: 20894144

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.14.2008 at 09:11AM PST, ID: 20895112

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 12:07AM PST, ID: 20900073

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.13.2008 at 07:12AM PST, ID: 20884780

Rank: Genius

Try something like this:

   oleDbReader.GetDouble(oleDbReader.GetOrdinal("Number"))

Bob
 
02.13.2008 at 07:14AM PST, ID: 20884807

Rank: Guru

Why don't you just try retrieving the value and then casting it in VB.NET?  Or, you can just let VB do the
casting for you.

For example:

'Let VB do the casting
Dim value as Int32 = oleDbReader(1)

'Cast it yourself.
Dim value as Int32 = Int32.Parse(oleDbReader(1))

'If you still have problems with those casts, try using Int64, just in case the numbers are too big:
Dim value as Int64 = oleDbReader(1)

'Or:
Dim value as Int64 = Int64.Parse(oleDbReader(1))


VBRocks


 
02.13.2008 at 07:37AM PST, ID: 20885037
Thank you both for your responses.
 oleDbReader.GetDouble(oleDbReader.GetOrdinal("Number")) was the same as  oleDbReader.GetDouble(?) which I had already tried and doesn't work.

Dim value as Int32 = oleDbReader(1) and Dim value as Int32 = Int32.Parse(oleDbReader(1)) return the integer part of the number but not the decimal e.g. my VFP value of numeric (11,7) contained 123.4567890 and in VB I only see 123.
The final option  Dim value as Int64 = Int64.Parse(oleDbReader(1)) errors with 'Input string was not in a correct format.'
So near and yet so far!!
 
02.13.2008 at 07:42AM PST, ID: 20885090

Rank: Guru

Well, try using the Double datatype, like Bob mentioned, but try using my approach, like this:

  Dim value as Double = Double.Parse(oleDbReader(1))

Accepted Solution
 
02.13.2008 at 08:02AM PST, ID: 20885273
Thats works in that it gives me the correct value in 'value', but the odd thing is when I write these values into my table I just see NULLs.
The destination table is SQL CE and the columns they end up in are created by:
CREATE TABLE.....       ........Latitude numeric(10,7) NULL, Longitude numeric(10,7) NULL, Eastings numeric(9,1) NULL, Northings numeric(9,1) NULL)
Is this another cast error?
 
02.13.2008 at 08:06AM PST, ID: 20885307

Rank: Guru

It is not a casting error.  Can you show me the code you are using the write them into your table?

Also, please show me the code you are using the "view" the data that is in your table.  
(This would be the data that is in the table BEFORE you update your SQL tables.

 
02.13.2008 at 08:11AM PST, ID: 20885364
The code is below.
There is no data in the table prior to this as the database and table are created each time.
I'm looking at the created data on a PDA with the SQL CE utility.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
        oleDbReader = oleDbCmd.ExecuteReader()
        While oleDbReader.Read()
            sqlCeRowset.PrepareRow()
            sqlCeRowset.SetValue(1, oleDbReader.GetInt32(0))        ' ID 
            sqlCeRowset.SetValue(2, oleDbReader.GetInt32(1))        ' Psi_Pipeline_Id
            sqlCeRowset.SetValue(3, oleDbReader.GetString(2))       ' Key
            sqlCeRowset.SetValue(4, oleDbReader.GetString(3))       ' Description
            sqlCeRowset.SetValue(5, oleDbReader.GetString(4))       ' Location Description
            sqlCeRowset.SetValue(6, oleDbReader.GetString(5))       ' Abbreviation - Show_on_Graph Skipped (6)
            'sqlCeRowset.SetValue(7, oleDbReader.GetFloat(7))        ' Latitude
 
            value = Double.Parse(oleDbReader(7))
            sqlCeRowset.SetValue(7, value)
            value = Double.Parse(oleDbReader(8))
            sqlCeRowset.SetValue(8, value)        ' Longitude
            value = Double.Parse(oleDbReader(9))
            sqlCeRowset.SetValue(9, value)       ' Eastings
            value = Double.Parse(oleDbReader(10))
            sqlCeRowset.SetValue(10, value)      ' Northings
            sqlCeRowset.Insert()
        End While
Open in New Window
 
02.13.2008 at 01:53PM PST, ID: 20888670

Rank: Guru

Hi VFPSQLDeveloper,

Sorry I didn't get back to you sooner, I didn't realize you posted.

Unfortunately, I'll have to admit that I'm not familiar with SQL CE, so I'm not going to be much help.  Sorry.

One question I have, can you place a break point on the first line, and then step through each line,
checking to make sure that the variable "value" actually has a value.

            'Place your breakpoint on this line:
            value = Double.Parse(oleDbReader(7))

            'Step once to here, then check the "value" variable and see if it has a value.
            sqlCeRowset.SetValue(7, value)

            'Do the same thing for the remaining row.
            value = Double.Parse(oleDbReader(8))
            sqlCeRowset.SetValue(8, value)        ' Longitude
            value = Double.Parse(oleDbReader(9))
            sqlCeRowset.SetValue(9, value)       ' Eastings
            value = Double.Parse(oleDbReader(10))
            sqlCeRowset.SetValue(10, value)      ' Northings

            'If the "value" variable has a value after every Parse, then break on the line below, and check
            '  each column in your row, before it's added to the table, and verify data is there.

            sqlCeRowset.Insert()

 
02.14.2008 at 07:36AM PST, ID: 20894144
Hi VBRocks,
No worries about the delay, I had to go away yesterday anyhow.
There is the correct value in 'value' after Double.Parse(oleDbReader(7)).

When I break it at sqlCeRowset.Insert() I get error 'Cannot convert data type to double.' if I do:
? sqlCeRowset.GetDouble(7)

But ? sqlCeRowset.GetDecimal(7) returns: 123.456789D which is the correct value.

 
02.14.2008 at 09:11AM PST, ID: 20895112

Rank: Guru

So it looks like the value in the row (before it is added to the table) is getting set correctly.  

When you complete the Insert, and add the row to the table, what happens?  Is there a Null, or is the value there? If it is a Null, then (obviously) you have a problem with your Insert.  Double-Check the
DataType of the column in the Table.

 
02.15.2008 at 12:07AM PST, ID: 20900073
I'm not sure how to interrogate the value after the insert or how to check the DataType.
 
 
02.22.2008 at 02:32AM PST, ID: 20956039
Thanks VBRocks.
Your posting regarding my original problem was correct and solved that problem.
My subsequent problems actually turned out to be a bug in the utility I was using to access the SQL CE tables on the PDA so you couldn;t have helped with this!
 
 
 
20080716-EE-VQP-33 / EE_QW_2_20070628