borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How can I delete a printer)Next Topic (Probem with selected items FileListBox) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Inserting Column Fields to existing Table
Poster Message
russell214
Level: Scholar

Registered: 02-03-2006
Posts: 32

icon Inserting Column Fields to existing Table

hi to everyone!!!

i'm new in VB programming. my problem is how can i add column field in a table based on range of two DatetimePicker?

for example:

DTPBegin = "02/06/2006"
DTPEnd = "02/08/2006"

result should be:

---------------------------------------------------
  02/06/2006  |  02/07/2006  |  02/08/2006
---------------------------------------------------

thank you in advance...

02-03-2006 at 03:29 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Inserting Column Fields to existing Table

Hi Russell,
Can you be a bit more specific.
What version of VB are you using VB6, VB.NET 2003(v1.1), VB.NET 2005(v2)
What table do you mean, Access Database table, SQL-Server table, a table on your form
If you mean a database table how are you connecting to it - ADO, DAO, DataEnvironment, ADODC. DataAdapter.



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

02-03-2006 at 02:31 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Inserting Column Fields to existing Table

Why would you want to do that? One of the rules of database programming is never to store values in a table that can easily be calculated...

____________________________
If you find the answer helpful, please mark this topic as solved.

02-03-2006 at 02:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Inserting Column Fields to existing Table

I think it'd be easier (and have a lot fewer columns), to just have a "date" column, and put in the date in the column, not have a column for the date itself.

to create a column itself (add it to the table), it's similar to:
ALTER [tablename] ADD COL [colname](type size)
ALTER `tablename` ADD COL `colname` type size

but it all depends on the database enging itself...



____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

02-03-2006 at 10:56 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
russell214
Level: Scholar

Registered: 02-03-2006
Posts: 32
icon Re: Inserting Column Fields to existing Table

i'm using VB6 and MS Access database, and the connection is ADODC and ADODB. ADODB on one form only (frmCutOff) and the rest ADODC.

i already solved this problem. but i want to remove the saturday and sunday based on the date range. but the result i get is not correct. can anyone modify my code. thanks in advance.

here is my code:

Private Sub cmdProcess_Click()

Dim cn As ADODB.Connection
Dim strsql As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Project\cutoff.mdb;Persist Security Info=False"
cn.Open

Dim d As Integer, i As Integer
Dim begindate  As Date
Dim enddate As Date
begindate = DTPicker1
enddate = DTPicker2
d = DateDiff("d", begindate, enddate)
For i = 0 To d
    If Not (Weekday(i) = vbSaturday) Or Not (Weekday(i) = vbSunday) Then
    strsql = "ALTER TABLE tblrange ADD [" & DateAdd("d", i, begindate) & "] datetime"
     cn.Execute strsql
   End If
Next

End Sub

03-03-2006 at 01:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: Inserting Column Fields to existing Table

Change OR to AND.......

____________________________
If you find the answer helpful, please mark this topic as solved.

03-03-2006 at 06:42 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Inserting Column Fields to existing Table
Previous Topic (How can I delete a printer)Next Topic (Probem with selected items FileListBox) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder