|
-
Apr 15th, 2013, 02:41 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Create Tables
Hi
In the Below code tables are created in Master , whereas tables should be created in MyDatabase.
Dim str As String
Dim sql As String
Dim str_use As String
str = "CREATE DATABASE MyDatabase ON PRIMARY " & _
"(NAME = MyDatabase_Data, " & _
" FILENAME = 'E:\T01-02.mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = MyDatabase_Log, " & _
" FILENAME = 'E:\T01-02.ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) "
conFind.Execute (str)
str_use = "Use MyDatabase"
conFind.Execute (str_use)
sql = "Create table VType(" & _
"[vtype] [nvarchar](20)" & _
"Primary Key([VType]))"
conFind.Execute (sql)
Thanks
-
Apr 15th, 2013, 01:27 PM
#2
Re: Create Tables
Thread moved to the 'Database Development' forum - which is where you should always post Database/SQL specific questions (while Databases and SQL can be used in VB, they are certainly not specific to VB)
-
Apr 15th, 2013, 06:39 PM
#3
Re: Create Tables
Try
Code:
sql = "Create table MyDatabase.VType(" & _
"[vtype] [nvarchar](20)" & _
"Primary Key([VType]))"
conFind.Execute (sql)
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
Apr 16th, 2013, 12:08 AM
#4
Thread Starter
Fanatic Member
Re: Create Tables
Hi
It is giving error "Specified Schema does not exists or you don't have permission to use it ".
MyDatabase exists
Thanks
-
Apr 16th, 2013, 10:48 AM
#5
Re: [RESOLVED] Create Tables
In my case I use dbo as schema, try : MyDatabase.dbo.VType
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
-
Apr 16th, 2013, 02:49 PM
#6
Re: [RESOLVED] Create Tables
dbo is the "DataBaseOwner" ... not the schema... the full format is Schema.Owner.Object... at any rate... the reason it didn't work originally was because it was using the original connection which was tied to the master database... once the database is created, close the connection, and re-open it, this time using the new database as the schema... then your create tables will work as expected.
-tg
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
|