Results 1 to 10 of 10

Thread: ASP.net Create Table help Code Included

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99

    ASP.net Create Table help Code Included

    Code:
    Sub CreateDatabase(ByVal dbName As String)
    
        Dim connectionString As String = "server='(local)'; trusted_connection=true; database='DNScards'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
    
        Try
            dim cmdCreate as string = "CREATE DATABASE [" & dbName & "]"
            Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
            dbCommand.CommandText = cmdCreate
            dbCommand.Connection = dbConnection
    
            dbConnection.Open
            dbCommand.ExecuteNonQuery
        Finally
            dbConnection.Close
        End Try
    End Sub
    any one see any problems with my code? dosent give me any errors, but also dosent work, tho i think it should, please help mr fix it

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    How could you know that it isn't giving you errors? You have a Try and a Finally, but no Catch portion to trap potential exceptions. Add a Catch to your Try block and see if an Exception is raised.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99
    try and catch in asp.net? does that even work?

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Yup, its just VB.NET after all. ASP is just the technology to render the output, but you are still running a VB.NET dll, with all the same syntax and everything available to a desktop app.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99
    not sure how to debug in real time tho, do i have to take a look through the broweser? or can i do it in the ide?

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You can set breakpoints in your code just like normal, and run it through the IDE. Execution should pause at the breakpoints like you would expect.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99
    ok wicked i'll give it a try in about an hour

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Or in your Catch block, write to the console or even the page.

    It should look something like this

    VB Code:
    1. Try
    2. 'All that code
    3. Catch ex As Exception
    4.    'write ex.Message.ToString
    5.  
    6. Catch sqlx As SqlException
    7.     'sqlx.Message.ToString
    8.  
    9. Finally

    etc, etc, etc.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99
    right this is confusing the hell out of me now, opened what i originaly wrote in visual studio, but no code, i wrote it in web matrix coz that is the bomb for asp.net stuff, bloody code is gone arrrggg, can the try catch still be achived in web matrix, since there is still no one product that is visual studio, web matrix, dreamweaver combind, unless VWDE is that tool

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    UK
    Posts
    99
    ok ok, i messed up sorry, can you see the code, thats creting a new database, that works, can you see the title, i wanted to make a new table, dam im stupid sometimes, ok, now i captured that, any ideas on adding a new table to a database

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width