VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
creating table during run time in vb.net - urgent!!!!!!!! Posted by aswinanu on 3 Jan 2007 at 11:18 PM
hi
in my project i want tables to be created automatically during runtime
for each user who are all creating new id
Report
Re: creating table during run time in vb.net - urgent!!!!!!!! Posted by PavlinII on 6 Jan 2007 at 9:54 AM
: hi
: in my project i want tables to be created automatically during runtime
: for each user who are all creating new id
:
Hi,
do you think that starting new thread for the same question is a good idea?

Are you absolutely sure that you need table for every user?
2 key column table does not solve your problem?

Let's say
...you need to create table with name User_Table_X where X is ID of your current user that needs to create own table.
...table has 2 columns (ID INT NOT NULL PRIMARY KEY IDENTITY(1, 1) and Value VARCHAR(255))
    Private Sub CreateUserTable(ByVal id_User As Integer)
        Dim sqlConn As New SqlConnection("Place your SQL Connection String HERE")
        Dim cCreTab As New SqlCommand("CREATE TABLE User_Table_" & id_User & " (" & _
            "ID INT NOT NULL PRIMARY KEY IDENTITY(1, 1), " & _
            "Value VARCHAR(255) NOT NULL DEFAULT(''))", sqlConn)
        sqlConn.Open()
        Try
            cCreTab.ExecuteNonQuery()
        Finally
            sqlConn.Close()  'XXX
        End Try
    End Sub
XXX - allways make sure that you close your connections, even if error occurs
(You can also use Using statement for accomplish this Try-Finally block)

After calling CreateUserTable(10) is created table with name User_Table_10

Hope this helps
And please, if you have another question about this block, reply to this message and do not create a new thread

Pavlin II[/size]

Don't take life too seriously anyway you won't escape alive from it!





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.