با sql server هم امتحان کردم اما نشد!! اگر میشه با sql server بگید چگونه این کارو انجام بدم!
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class sqlserver
{
public void create_db(string db_name)
{
String str;
SqlConnection myConn = new SqlConnection("Server=localhost;Integrated security=SSPI;database=master");
str = "CREATE DATABASE MyDatabase ON PRIMARY " +
"(NAME = MyDatabase_Data, " +
"FILENAME = 'C:\\MyDatabaseData.mdf', " +
"SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
"LOG ON (NAME = MyDatabase_Log, " +
"FILENAME = 'C:\\MyDatabaseLog.ldf', " +
"SIZE = 1MB, " +
"MAXSIZE = 5MB, " +
"FILEGROWTH = 10%)";
SqlCommand myCommand = new SqlCommand(str, myConn);
try
{
myConn.Open();
myCommand.ExecuteNonQuery();
//"DataBase is Created Successfully"
}
catch (System.Exception ex)
{
//ex.ToString()
}
finally
{
if (myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}
}