Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21839

Create Database & Attach Existing File

$
0
0
Hi

I may have repeated this question . I want to create New Database & attach existing file to it . How it can be done.
I have written the below Code it gives message file already exists


Set myConn = New ADODB.Connection
myConn.ConnectionString = "Provider = sqloledb;Data Source=" & ServerName & ";uid=" & uid & ";pwd=" & pwd

str = "CREATE DATABASE MyDatabase ON PRIMARY " & _
"(NAME = MyDatabase_Data, " & _
" FILENAME = 'E:\test1.mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = MyDatabase_Log, " & _
" FILENAME = 'E:\test1.ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) "
myConn.Open
myConn.Execute (str)

Thanks

Viewing all articles
Browse latest Browse all 21839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>