creating table during run time in vb.net - urgent!!!!!!!! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

creating table during run time in vb.net - urgent!!!!!!!!

aswinanuaswinanu Posts: 13Member
hi
in my project i want tables to be created automatically during runtime
for each user who are all creating new id

Comments

  • PavlinIIPavlinII Posts: 404Member
    : 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))
    [code] 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() [green]'XXX[/green]
    End Try
    End Sub[/code]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

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.