|
-
Jul 21st, 2004, 01:20 PM
#1
Thread Starter
Lively Member
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
-
Jul 21st, 2004, 02:47 PM
#2
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
-
Jul 22nd, 2004, 05:26 AM
#3
Thread Starter
Lively Member
try and catch in asp.net? does that even work?
-
Jul 22nd, 2004, 05:35 AM
#4
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
-
Jul 22nd, 2004, 05:40 AM
#5
Thread Starter
Lively Member
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?
-
Jul 22nd, 2004, 05:45 AM
#6
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
-
Jul 22nd, 2004, 05:50 AM
#7
Thread Starter
Lively Member
ok wicked i'll give it a try in about an hour
-
Jul 22nd, 2004, 06:41 AM
#8
Or in your Catch block, write to the console or even the page.
It should look something like this
VB Code:
Try
'All that code
Catch ex As Exception
'write ex.Message.ToString
Catch sqlx As SqlException
'sqlx.Message.ToString
Finally
etc, etc, etc.
-
Jul 22nd, 2004, 07:28 AM
#9
Thread Starter
Lively Member
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
-
Jul 22nd, 2004, 07:47 AM
#10
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|