|
-
Sep 7th, 2011, 10:31 AM
#1
Thread Starter
New Member
Datetimpicker
Hi there!
Pls help me with my code
i want to save the values from these code wriiten below,but the value did not incremented after saving..please help me
thank you!
vb.net Code:
Dim startDate = Date.Today
Dim endDate = DateTimePicker1.Value.Date
Do While startDate <= endDate
MsgBox(startDate.ToShortDateString)
startDate = startDate.AddMonths(1)
Loop
strSQL = "Insert into Lenders_CollectDate (TransactionID,DateCollect_1,dateCollect_2,DateCollect_3) values ('" & txtTransacID.Text & "','" & startDate.ToShortDateString & "','" & startDate.ToShortDateString & "','" & startDate.ToShortDateString & "')"
SQLalter_Table(strSQL)
MsgBox("Ok")
-
Sep 7th, 2011, 10:35 AM
#2
Re: Datetimpicker
Perhaps moving your INSERT inside the loop would be more along the lines of what you are after.
As it is, it is only inserting one record using the last date calcuated.
-
Sep 7th, 2011, 11:01 AM
#3
Re: Datetimpicker
Seems the code responsible for the update in regards to SQLalter_Table(strSQL) which you have not shown is where the problem is. Unless you show this code all that can be done is guess so best to show your code.
-
Sep 7th, 2011, 11:01 AM
#4
Re: Datetimpicker
what are the datatypes of:
TransactionID
DateCollect_1
dateCollect_2
DateCollect_3
???
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Sep 7th, 2011, 11:29 AM
#5
Thread Starter
New Member
Re: Datetimpicker
sorry for incomplete information..to make it clear
date Today is 09/08/2011
selected date from datetimepicker is 01/08/2012
for example I want to save the value of
09/09/2011-Firstmonth
10/09/2011-SecondMonth
11/09/2011-thirdMonth
12/09/2011-FourthMonth
01/09/2012-FifthMonth
until it reached the selected value from datetimpicker.
Pls.Help me..
Thank you very much!
-
Sep 7th, 2011, 11:39 AM
#6
Re: Datetimpicker
What does SQLalter_Table(strSQL) do ???
-
Sep 7th, 2011, 11:42 AM
#7
Thread Starter
New Member
Re: Datetimpicker
I just want to save the incremented months to my database...
using (do while) but it gives me values that i'm selected not the incremented values...
pls help me...
-
Sep 7th, 2011, 11:43 AM
#8
Thread Starter
New Member
Re: Datetimpicker
SqlAlterTable- that is my function to save and update values on my database..
-
Sep 7th, 2011, 11:45 AM
#9
Re: Datetimpicker
your call to the routine that inserts the values into the database is outside of the loop... move it into the loop and it just might work. Call me crazy, but it just might work.
-tg
-
Sep 7th, 2011, 12:25 PM
#10
Hyperactive Member
Re: Datetimpicker
Techgnome has already provided a solution to the sql insert problem. If the problem is about adding months to the target date specified in the Datetimepicker then, the following example could possibly help you.
vb.net Code:
Dim startDate = Date.Today
Dim endDate = DateTimePicker1.Value.Date
Do While endDate = DateTimePicker1.Value.Date
If startDate >= endDate Then Exit Do
startDate = startDate.AddMonths(1)
MsgBox(startDate.ToShortDateString)
Loop
-
Sep 14th, 2011, 12:24 PM
#11
Thread Starter
New Member
Re: Datetimpicker
Please Help!
How to get Semi-Annual(or every 6 months) using Datetimepicker?
-
Sep 14th, 2011, 01:34 PM
#12
Hyperactive Member
Re: Datetimpicker
 Originally Posted by ralphzxess
Please Help!
How to get Semi-Annual(or every 6 months) using Datetimepicker?
It sounds like you want to save all the 6 different dates on a single click. Do you have different fields like First_Month, Second_Month etc ? Or trying to insert 6 rows all at once ? The exact problem is still unknown.
.
-
Sep 15th, 2011, 12:02 AM
#13
Thread Starter
New Member
Re: Datetimpicker
To make it clear...
I have a 2 datetimpicker,
This is my code
DateDIff(DateInterval.Year,Datetimpicker1,Datetimpicker2)/2
how can I get the dateinterval of Semi-Annual?
-
Sep 15th, 2011, 07:22 AM
#14
Hyperactive Member
Re: Datetimpicker
try this:
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SemiAnnual As Date = DateTimePicker2.Value
Dim MyDate As Date
Dim firstDate, msg As String
Dim secondDate As Date
MyDate = SemiAnnual.AddMonths(6)
DateTimePicker2.Value = MyDate
firstDate = DateTimePicker1.Value
secondDate = DateTimePicker2.Value
msg = "Months from today: " & DateDiff(DateInterval.Month, Now, secondDate)
MsgBox(msg)
End Sub
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
|