Click here to Skip to main content
16,015,393 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to create data base in c#(win app) by SMO.
My Code run correctly before,but it get erro now.

C#
string serverStr=ConfigurationManager.AppSettings["Server"];
ServerConnection con=new ServerConnection(serverStr);

Server srv=new Server(Con);

Microsoft.SqlServer.Management.Smo.DataBase newDB=new Microsoft.SqlServer.Management.Smo.DataBase(srv,'test');

newDB.Create();


this is the error: create failed for database 'test'
Posted
Updated 16-Nov-14 21:48pm
v3

1 solution

you have never used connection string when you create ServerConnection
Check this answer for sample code[^]
 
Share this answer
 
Comments
maliheSadat 17-Nov-14 5:47am    
I add the ServerConnection to ServerConnection.but my problem is not solved.

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