Results 1 to 5 of 5

Thread: [RESOLVED] SQL Query Split Record?

Threaded View

  1. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    101

    Re: SQL Query Split Record?

    Hi Si,

    I have tried what you have suggested but it throws out an SQL error. Is this because im inserting from a select statement??, how can I pass values from elsewhere within the same statement? as mentioned the Date does not come from the table but is user specified.

    here is my code so far:

    Code:
    'Allow the user to select start/end date from DateTimePickers
    Dim StartDate As DateTime = dtpStartDate.Value.Date
    Dim EndDate As DateTime = dtpEndDate.Value.Date
    Dim i As Integer
    Dim NumberOfDays As Integer
    
    'Calculate How many times the record must be added in the for loop
    NumberOfDays = EndDate.DayOfYear - StartDate.DayOfYear
    
    If MsgBox("You are about to insert into the table are you sure you wish to do this?", MsgBoxStyle.YesNo, "Insert INTO") = MsgBoxResult.Yes Then
    
    For i = 1 To NumberOfDays
    
    Dim SQL As String
    
    SQL = ("INSERT INTO tblTest (Code, Product, DaysCover, MaxDaysCover, InStock) SELECT Code, Product, DaysCover, MaxDaysCover, InStock FROM tblProducts WHERE IncludeInPlanning=True AND InStock=True")
    
    Next
    
    End If

    edit: actually after trying again its working.. cheers si!
    Last edited by enex; Feb 16th, 2010 at 08:47 AM. Reason: working code

Tags for this Thread

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