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
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Nov 28th, 2009, 12:39 PM   #1
billboy
Hyperactive Member
 
Join Date: Aug 09
Location: Los Angeles
Posts: 482
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 01:55 PM. Reason: wrong forum
billboy is offline   Reply With Quote
Old Nov 28th, 2009, 01:54 PM   #2
jggtz
Fanatic Member
 
Join Date: May 06
Location: the edge
Posts: 724
jggtz will become famous soon enough (65+)
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, 02:17 PM   #3
billboy
Hyperactive Member
 
Join Date: Aug 09
Location: Los Angeles
Posts: 482
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 offline   Reply With Quote
Old Nov 28th, 2009, 06:02 PM   #4
jggtz
Fanatic Member
 
Join Date: May 06
Location: the edge
Posts: 724
jggtz will become famous soon enough (65+)
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
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 05:11 AM.





Acceptable Use Policy

Internet.com
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.