GeoffS Level: VB Lord Registered: 29-09-2004 Posts: 536
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
|
Goran Level: Moderator Registered: 16-05-2002 Posts: 1681
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
|
JLRodgers Level: Moderator Registered: 04-04-2002 Posts: 1617
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)
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
|
Goran Level: Moderator Registered: 16-05-2002 Posts: 1681
Re: Inserting Column Fields to existing Table
Change OR to AND.......
____________________________
If you find the answer helpful, please mark this topic as solved.