hi to everybody
i'm new member to this site and i don't know where
can be a good place for creating this topic
pardon me for probable mistake.
i need to attach and detach the database in/from
sql server in vb.net with hard-code .i can do this
without using stored procedure and with SQL-DMO
But i can't checking The database Existence
for attaching it.now, how can i check the database
existense for preventing the attach operation.
please help me
thanks a lot
Hi,
using SMO you can use the following script:
new Server("SomeServer").Databases.Contains("SomeDatabase")
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||hi and thanks for your answer
where can i write that script
can you explain more by some example
thanks a lot
|||Hi,sure a small application would be (with no extensive exception handling)
using System;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.Win32;
namespace SMOProject
{
class Program
{
static void Main(string[] args)
{
Server s = new Server(args[0]);
if (s.Databases.Contains(args[1]))
Console.WriteLine(string.Format("Database {0} exists",args[1]));
}
}
}
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||that is brillient,
Sir could you tell me how to attach "database.dbf"?
Thanks
|||Hi,
if it is a non-SQL Server database file you will have to import from the file using the DTS Import wizard or any other tools which offer a driver for the dbf files.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
it is a database file
Thanks
|||But a non-sql server, right ? Or is it just a file which was named with the extension dbf instead of mdf or ndf ?
Jens K. Suessmeyer.
http://www.sqlserver2005.de
mmmmm Sory sir, i really forgotten
it is ".mdf"
Dont mind it
Thanks
|||If you have the logfile you can use sp_attachdb or the appropiate GUI task, if you don′t have the logfile you can use sp_attach_single_file_db. But this will only works if the database was closed correctly.
HTH, jens K. Suessmeyer.
http://www.sqlserver2005.de|||
Yes Sir, Problem Solved by following scripts
sp_attach_db 'nwd','C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\nwd.mdf',
'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\nwd_log.LDF'
No comments:
Post a Comment