To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Nov 28th, 2009, 01:39 PM   #1
billboy
Hyperactive Member
 
Join Date: Aug 09
Location: Los Angeles
Posts: 423
billboy is on a distinguished road (20+)
Resolved [RESOLVED] Select All Fileds and Cdbl for One

I am using the following code to get all my database fields, I would like to convert one of the fields to Cdbl, not sure how to do that

Dim comm As New OleDb.OleDbCommand("Select * From " & Me.OpenFileDialog1.SafeFileName & " Where Status <> 'S'", con)
I know how to individually do it field by field but i dont want to have to write a select for each field if that makes sense?

Dim comm2 As New OleDbCommand("Select Cdbl([Selling Price]) as SoldPrice, Status From " & Me.OpenFileDialog1.SafeFileName & " Where Status = 'S'", con)

So something that pulls ALL fields and converts one

sorry posted in wrong section, reposted in database development

Last edited by billboy; Nov 28th, 2009 at 02:55 PM. Reason: wrong forum
billboy is online now   Reply With Quote
Old Nov 28th, 2009, 02:54 PM   #2
jggtz
Fanatic Member
 
Join Date: May 06
Location: the edge
Posts: 536
jggtz  is on a distinguished road (40+)
Re: Select All Fileds and Cdbl for One

You can do it in SQL Server (never try using Access)
With the next query you'll obtain all the fields plus a new one named NewPrice at the end of all the existing fields
Remember to change the function Convert if you use other db instead of sql server
Code:
SELECT *, Convert(float,[Price]) As NewPrice
FROM [Report].[dbo].[Invoices]
jggtz is offline   Reply With Quote
Old Nov 28th, 2009, 03:17 PM   #3
billboy
Hyperactive Member
 
Join Date: Aug 09
Location: Los Angeles
Posts: 423
billboy is on a distinguished road (20+)
Re: Select All Fileds and Cdbl for One

Quote:
Originally Posted by jggtz View Post
You can do it in SQL Server (never try using Access)
With the next query you'll obtain all the fields plus a new one named NewPrice at the end of all the existing fields
Remember to change the function Convert if you use other db instead of sql server
Code:
SELECT *, Convert(float,[Price]) As NewPrice
FROM [Report].[dbo].[Invoices]
Dim comm As New OleDb.OleDbCommand("Select * , Cdbl([Listing Price]) as ListPrice, From " & Me.OpenFileDialog1.SafeFileName & " Where Status <> 'S'", con)

getting syntax error
any ideas?
billboy is online now   Reply With Quote
Old Nov 28th, 2009, 07:02 PM   #4
jggtz
Fanatic Member
 
Join Date: May 06
Location: the edge
Posts: 536
jggtz  is on a distinguished road (40+)
Re: [RESOLVED] Select All Fileds and Cdbl for One

What do you have in ---Me.OpenFileDialog1.SafeFileName ---?
I think that FROM clause needs a tablename and not a filename
jggtz is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:50 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.