Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13

    Unhappy Unanswered: float in VB-Skript

    Hi there
    I have two Databases
    in both databases are fields with float - no null
    If I am transfering data from one database to the other everything works well unless there is a comma in the field ( 0,99 or 123,456 )

    "SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti kelbezeichnung,Artikeltext1,EDVEingang ,EDVAusgang,InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & EDVEingang & "," & EDVAusgang & "," & ArtMenge & ")"
    "
    where EDVEingang and EDVAusgang are defined as float, no null

    Then the programm stops with the following message:
    Within the INSERT-Procedure there are less columns then there are Contents in the Value-Clause.

    I have to finish the programm until tomorrow morning and don't know what the problem is.

    If anybody has an idea, please let me know.

    regards
    Reiner

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    use cast(columnname as float) to avoid this kind of errors !!!
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Thanks for your quick answer,
    but if I'm trying this :
    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti kelbezeichnung,Artikeltext1,cast(EDVEingang as float),EDVAusgang,InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & EDVEingang & "," & EDVAusgang & "," & ArtMenge & ")"

    I'm getting the error: Wrong Syntas near "("

    regards

  4. #4
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti
    kelbezeichnung,Artikeltext1,cast(EDVEingang as float),EDVAusgang,InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "EDVEingang & "," & EDVAusgang & "," & ArtMenge & ")"

    You need to use this
    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti
    kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang, InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "cast (" & EDVEingang &" as float) ," & EDVAusgang & "," & ArtMenge & ")"
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  5. #5
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by Enigma
    You need to use this
    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti
    kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang, InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "cast (" & EDVEingang &" as float) ," & EDVAusgang & "," & ArtMenge & ")"

    Thanks again.
    I did as you advised and got the error : wrong syntas near "as"

    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang, InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "cast (" & EDVEingang & " as float)," & EDVAusgang & "," & ArtMenge & ")"

  6. #6
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Try this

    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti
    kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang,
    InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "convert(float," & EDVEingang & ")," & EDVAusgang & "," & ArtMenge & ")"
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  7. #7
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by Enigma
    Try this

    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti
    kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang,
    InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "convert(float," & EDVEingang & ")," & EDVAusgang & "," & ArtMenge & ")"
    I have tried this. No error is coming up any more, but all decimal values are rounded: 263,2569 => 263 142,7402 => 142

  8. #8
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by ReinerS
    I have tried this. No error is coming up any more, but all decimal values are rounded: 263,2569 => 263 142,7402 => 142
    Is there anybody who has an idea about the problem with the figures after the decimal point?

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You sure?

    What's the DDL of the Table?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  10. #10
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by Brett Kaiser
    You sure?

    What's the DDL of the Table?
    What do you mean with DDL of the Table

  11. #11
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Data Definition Language (DDL)...

    Go to Enterprise Manager (EM) right click on the table go to all tasks, script database...preview Copy and paste the CREATE TABLE myTable99 (Col1 int, ect...

    statement here....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  12. #12
    Join Date
    Oct 2003
    Posts
    706
    Originally posted by ReinerS
    Thanks again.
    I did as you advised and got the error : wrong syntas near "as"
    SQLAString = "Insert into InventurDaten (Artikelnummer,Hauptartikelnummer,Auspraegung,Arti kelbezeichnung,Artikeltext1,EDVEingang,EDVAusgang, InventurmengeEDV) values ('" & ArtNr & "','" & ArtNrT & "','" & AP & "','" & ArtBez & "','" & ArtText & "'," & "cast (" & EDVEingang & " as float)," & EDVAusgang & "," & ArtMenge & ")"
    I suspect that "cast .. as .." was intended to be a visual basic function-call not part of the SQL statement but I'm not quite sure.

    Is the "locale" setting for this workstation in-sync with what the SQL server expects?

    The bottom line is: Different countries obviously use different meanings for "," vs. "." in a number and both the DBMS and the workstation should, in their own way, be prepared to handle it once you (in the appropriate way, whatever it is) tell them to do so. There may be options that you can set for one of the connection objects. Look for "national language" and so-on in the various pieces of documentation/help. Or "internationalization."

    This is a classic internationalization-issue, and it has been "solved."
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  13. #13
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by Brett Kaiser
    Data Definition Language (DDL)...

    Go to Enterprise Manager (EM) right click on the table go to all tasks, script database...preview Copy and paste the CREATE TABLE myTable99 (Col1 int, ect...

    statement here....

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[InventurDaten]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[InventurDaten]
    GO

    CREATE TABLE [dbo].[InventurDaten] (
    [Artikelnummer] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
    [Hauptartikelnummer] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
    [Auspraegung] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,
    [Artikelbezeichnung] [varchar] (100) COLLATE Latin1_General_CI_AS NULL ,
    [Artikeltext1] [varchar] (100) COLLATE Latin1_General_CI_AS NULL ,
    [EDVEingang] [float] NULL ,
    [EDVAusgang] [float] NULL ,
    [InventurmengeEDV] [float] NULL ,
    [Inventurdatum] [datetime] NULL ,
    [Inventurzaehlmenge] [float] NULL ,
    [Inventurdifferenz] [float] NULL ,
    [EKPreis] [float] NULL ,
    [Inventurbetrag] [float] NULL ,
    [Inventurdifferenzbetrag] [float] NULL ,
    [EDVWertEingang] [float] NULL ,
    [EDVWertAusgang] [float] NULL ,
    [EDVUmsatzJahr] [float] NULL ,
    [EDVRohertragJahr] [float] NULL ,
    [EDVEinstandspreis] [float] NULL ,
    [EDVRabatte] [float] NULL ,
    [EDVWertProduktion] [float] NULL ,
    [EDVMengeProduktion] [float] NULL ,
    [EDVBezugskosten] [float] NULL
    ) ON [PRIMARY]
    GO

  14. #14
    Join Date
    Feb 2002
    Posts
    2,232
    Please post the ddl for both tables.

  15. #15
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    13
    Originally posted by rnealejr
    Please post the ddl for both tables.
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T0302003]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[T0302003]
    GO

    CREATE TABLE [dbo].[T0302003] (
    [C008] [float] NOT NULL ,
    [C009] [float] NOT NULL ,
    [C012] [float] NOT NULL ,
    [C013] [float] NOT NULL ,
    [C015] [varchar] (30) COLLATE Latin1_General_CI_AS NOT NULL ,
    [C017] [float] NOT NULL ,
    [C018] [float] NOT NULL ,
    [C019] [float] NOT NULL ,
    [C021] [datetime] NULL ,
    [C022] [datetime] NULL ,
    [C024] [float] NOT NULL ,
    [C026] [float] NOT NULL ,
    [C031] [float] NOT NULL ,
    [C032] [varchar] (1) COLLATE Latin1_General_CI_AS NULL ,
    [C033] [float] NOT NULL ,
    [C034] [float] NOT NULL ,
    [C042] [float] NOT NULL ,
    [C044] [float] NOT NULL ,
    [C054] [float] NOT NULL ,
    [C059] [float] NOT NULL ,
    [C060] [datetime] NULL ,
    [C079] [int] NOT NULL ,
    [C100] [varchar] (1) COLLATE Latin1_General_CI_AS NULL ,
    [C101] [datetime] NULL ,
    [C102] [float] NOT NULL ,
    [C103] [varchar] (20) COLLATE Latin1_General_CI_AS NULL ,
    [C104] [datetime] NULL ,
    [C105] [varchar] (20) COLLATE Latin1_General_CI_AS NULL ,
    [C118] [float] NOT NULL ,
    [C119] [float] NOT NULL ,
    [C120] [float] NOT NULL ,
    [ts] [timestamp] NULL
    ) ON [PRIMARY]
    GO


    [C012] => EDVWertEingang
    [C013] => EDVWertAusgang

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •