Click here to Skip to main content
15,916,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi friends I want to create sql database on client pc through coding using smo
I am using following code to create database on client pc but it gives me an error that "create failed for database "database name""
my code is
C#
string srvname = "MY-PC/SPARTAN";
Server srv;
srv = new Server(srvname);
Database db;
db = new Database(srv, "iji");

but at last line it gives above error .please help me.
Posted
Updated 25-Nov-11 3:59am
v2

1 solution

You use a backslash to separate the server name from the SQL Server database instance name. Try
C#
string srvname = "MY-PC\\SPARTAN";
 
Share this answer
 
Comments
maheshpardeshi 25-Nov-11 9:35am    
DataTable dataTable = SmoApplication.EnumAvailableSqlServers(false);
I have use it it directly takes instance name & it is
"MY-PC\\SPARTAN" then also geting error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900