DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: 'input string was not in correct format'

  1. #1
    Join Date
    Jul 2006
    Posts
    3

    'input string was not in correct format'

    Hi,

    d1 is date
    bID is integer
    Whats wrong with following sql statement while concatnetion

    strSQL = "Insert into sessiondelayed (batchid,ActualEndDate) values (" & bID & ",'" & d1 & "')"

    This is throwing error that 'input string was not in correct format'

    Swati
    Last edited by b_swati; 07-12-2006 at 04:47 AM. Reason: statements missing

  2. #2
    Join Date
    Dec 2004
    Posts
    717
    Quote Originally Posted by b_swati
    strSQL = "Insert into sessiondelayed (batchid,ActualEndDate) values (" & bID & ",'" & d1 & "')"

    This is throwing error that 'input string was not in correct format'

    Swati
    Hi Swati,

    I guess that one of the value of variables (bID or d1) is missing in your coding.
    Let me tell you one useful way to debug the SQL Statement..
    1) Set the breakpoint on the line.
    2) Run the project.
    3) Check the value of the varibale "strSQL" after the debugging line has passed to the next line.
    eg: maybe. you might see like ."Insert into sessiondelayed (batchid,ActualEndDate) values (1,'aa')"
    Note: ensure that the value of "bID" and "d1" are shown in the string.

    4) Then copy this value..
    5) Paste it in the SQL Query Analyzer (if you are using SQL db).
    6) then, Execute this string which is pasted in Query.
    Note: You will see the reason why your statement is faild to execute.

    P.S: If you still dont know what the problem is, please post the value of "strSQL" statement (Step 3) after debugging.

    Hope you may find it useful..
    Best Regards,
    Michael Sync
    http://michaelsync.net

    The more you share,The more you get

  3. #3
    Join Date
    Dec 2003
    Posts
    2,750
    If I had to take guess, I would say that since you're using a string variable for your Date it probably isn't in the format expected by the database.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  4. #4
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    I'm with Paul on this one.

    Try outputting the strSQL variable after you have it built. Copy that and run it in Query Analyzer (or a similar tool) and see if the insert works.

    If it doesn't, then you found your problem.

Similar Threads

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 12:18 PM
  2. Input string was not in a correct format
    By kenn_rosie in forum .NET
    Replies: 2
    Last Post: 01-11-2006, 10:28 AM
  3. Input string was not in a correct format.error
    By naijacoder in forum ASP.NET
    Replies: 6
    Last Post: 11-10-2005, 03:54 AM
  4. Input string was not in a correct format.
    By ewarmour in forum ASP.NET
    Replies: 0
    Last Post: 03-27-2003, 02:36 PM
  5. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center