Results 1 to 4 of 4

Thread: [RESOLVED] Select All Fileds and Cdbl for One

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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]

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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?

  4. #4
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    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
  •  



Click Here to Expand Forum to Full Width