Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 20th, 2007, 08:43 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to djobes31770 Send a message via Yahoo to djobes31770
Default Create new Table in access

I am trying to port this app over, and i need to know, if it is possible to create a table in access dynamically or thru code. The app i have been building is based on RealBasic, and i can create a table like this:

Code:
  db = mnuSystemName.Text


  App.IATrackDB.SQLExecute "create table "+ db +" (SystemName varchar, AssignedIAControl varchar,Implementation varchar, ResponsibleEntity varchar, Resources varchar, EstCompletionDate varchar,DateStarted varchar, PackageID varchar, POC varchar, ComponentName varchar)"
My question is using the DataTable in VB, can i create a table in access the same way or similar.

Reply With Quote
  #2 (permalink)  
Old November 20th, 2007, 08:49 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

what do you mean by using datatable?? are you asking if you can execute a create table from a datatable??

you can use standard SQL (like that create) using a connection object and a command object, and using the function
executenonquery from the command object (just take care with the type of field definition, could be a little tricky)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #3 (permalink)  
Old November 20th, 2007, 09:17 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to djobes31770 Send a message via Yahoo to djobes31770
Default

Yes, I want to create a new table foreach PackageID Entered. I tried a SQL query, but then i found in the online help, a way to do it, but it doesnt work either. I am using the basic commands i use for the DataGridView.

Code:
       ' Create a new DataTable.
        Dim dadapter As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=iatrack.mdb")
        Dim table As DataTable = New DataTable("DPackages")

        ' Declare variables for DataColumn and DataRow objects.
        Dim column As DataColumn
        Dim row As DataRow

        ' Create new DataColumn, set DataType, ColumnName 
        ' and add to DataTable.    
        column = New DataColumn()
        column.DataType = System.Type.GetType("System.Int32")
        column.ColumnName = "id"
        column.ReadOnly = True
        column.Unique = True

        ' Add the Column to the DataColumnCollection.
        table.Columns.Add(column)

        ' Create second column.
        column = New DataColumn()
        column.DataType = System.Type.GetType("System.String")
        column.ColumnName = "PackageID"
        column.AutoIncrement = False
        column.Caption = "PackageID"
        column.ReadOnly = False
        column.Unique = False

        ' Add the column to the table.
        table.Columns.Add(column)

        ' Make the ID column the primary key column.
        Dim PrimaryKeyColumns(0) As DataColumn
        PrimaryKeyColumns(0) = table.Columns("id")
        table.PrimaryKey = PrimaryKeyColumns

        ' Instantiate the DataSet variable.
        DataSet = New DataSet() Error on line

        ' Add the new DataTable to the DataSet.
        DataSet.Tables.Add(table)Referance to non-shared member error
But im getting an error on the DataSet type cannot be used as expression. I got this from the online help, and tried to modify based on the same issues from my other post's, the SQL error just gave me all string format errors, so i deleted and started from scratch with this, it looks cleaner if i can get it to work, still reading the pages.

Reply With Quote
  #4 (permalink)  
Old November 20th, 2007, 09:33 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. if DataSet is a reserved word, why are you using it like a variable name??????



HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #5 (permalink)  
Old November 20th, 2007, 09:37 AM
Authorized User
 
Join Date: Nov 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to djobes31770 Send a message via Yahoo to djobes31770
Default

Yea , i saw that, i did nnot need to redefine it. It now goes on, just doesnt load the data. Thanks Again.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create generic XSL Template to create table Venkatachalapathy XSLT 5 March 11th, 2008 07:49 AM
create SQL Server table from Access PorcupineRabbit SQL Server DTS 2 December 30th, 2005 06:11 AM
Create table from another table using ADO Kaustav Pro VB Databases 0 October 15th, 2005 05:44 AM
Create table statement syntax error in access 2000 method Access 1 August 8th, 2005 02:10 AM
How to create table in Ms Access (TSQL) abdusalam SQL Server 2000 4 July 31st, 2004 01:54 AM



All times are GMT -4. The time now is 05:56 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.