|
-
Nov 28th, 2009, 01:39 PM
#1
Thread Starter
Frenzied Member
[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
-
Nov 28th, 2009, 02:54 PM
#2
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]
-
Nov 28th, 2009, 03:17 PM
#3
Thread Starter
Frenzied Member
Re: Select All Fileds and Cdbl for One
 Originally Posted by jggtz
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?
-
Nov 28th, 2009, 07:02 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|