Problem dropping a (localDB)\v11.0 table programatically within a VS 2013 application.
Posted on 2015-02-04
I created a (localdb)\v11.0 database in Visual Studio 2013 programmatically with Visual Basic.
Dim SQLcon as New SqlConnection
Dim SQLstr as string
Dim cmd1 As SqlCommand
Dim cmd2 As SqlCommand
Dim cmd3 As SqlCommand
gSQLcon.ConnectionString = "Integrated Security=SSPI;" + "Initial Catalog=;" + "Data Source=(LocalDB)\v11.0"
SQLstr = "CREATE DATABASE family ON PRIMARY" + "(Name=family, filename = '" + "c:\family.mdf', size=10," + "maxsize=20, filegrowth=10%)log on " + _
"(name=family_log, filename = '" + "c:\family.ldf',size=10," + "maxsize=20,filegrowth=1)"
cmd1 = New SqlCommand(SQLstr, gSQLcon)
The database was created successfully. I then created a table in the database.
Dim gSQLconFamily As New SqlConnection
gSQLconFamily.ConnectionString = "Integrated Security=SSPI;" + "Initial Catalog=family;" + "Data Source=(LocalDB)\v11.0""
SQLstr = "CREATE TABLE member (nmbr numeric(7, 0) NULL)"
cmd2 = New SqlCommand(SQLstr, gSQLconFamily)
The table was created successfully. I then attempted to drop the table created.
SQLstr = "DROP TABLE member"
cmd3 = New SqlCommand(SQLstr, gSQLconFamily)
The attempt to drop the table was unsuccessful and I got the following message:
"Cannot drop the table 'member', because it does not exist or you do not have permission."
The table existed and so the error must have been because I didn't have permission. Why would I not have permission to drop the table when I had just created it?