PDA

View Full Version : مهم - حیاتی - ساختم دیتابیس در sql server 2000



mrfatahi
دوشنبه 07 بهمن 1387, 20:29 عصر
سلام دوستان

من خودم sql server 2008 دارم ولی الان باید 2 تا دیتابیس با ورژن 2000 بسازم . کسی هست این کار رو برام بکنه ؟ وقت زیادی نمی گیره . لطفا اگه کسی به sql server 2000 دسترسی داره اعلام کنه چون من دسترسی به 2000 ندارم.

منتظرم
مرسی

ali_samadi
سه شنبه 08 بهمن 1387, 07:44 صبح
SqlConnection con;
SqlCommand com;
SqlDataReader dr;
SqlConnection con1;
SqlCommand com1;
SqlConnection con2;
SqlCommand com2;
public void createdb()
{
con = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True");
com = new SqlCommand();
com.Connection = con;
// com.CommandType = CommandType.Text;
com.CommandText = "select name from sysdatabases where name = 'Petro'";
con.Open();
dr = com.ExecuteReader();
if (!dr.HasRows)
{
con1 = new SqlConnection("Data Source=.;Initial Catalog=;Integrated Security=True");
com1 = new SqlCommand();
com1.Connection = con1;
//com1.CommandType = CommandType.Text;
com1.CommandText = "create database Petro on primary" + "(name =mdatabase,filename = 'c:\\Petro.mdf',size = 3)log on" + "(name = mdatabase_log,filename = 'c:\\Petro.Ldf') " + " COLLATE Arabic_CI_AS ";
con1.Open();
com1.ExecuteNonQuery();
con1.Close();
CreateTableAccount();
CreateTableServiceShow();

}
con.Close();
}
public void CreateTableAccount()
{
con2 = new SqlConnection("Data Source=.;Initial Catalog=Petro;Integrated Security=True");
com2 = new SqlCommand();
com2.Connection = con2;
//com2.CommandType = CommandType.Text;
com2.CommandText = "create table account (name nvarchar(50) primary key, pass nvarchar(50),type nvarchar(50))";
con2.Open();
com2.ExecuteNonQuery();
con2.Close();
}
public void CreateTableServiceShow()
{
con2 = new SqlConnection("Data Source=.;Initial Catalog=Petro;Integrated Security=True");
com2 = new SqlCommand();
com2.Connection = con2;
// com2.CommandType = CommandType.Text;
com2.CommandText = "create table Service (row int identity(1,1) primary key ,priority nvarchar(10),date nvarchar(20),time nvarchar(20),reqer nvarchar(20),unit nvarchar(20),tel nvarchar(20),number bigint,typeserv nvarchar(20),subject nvarchar(50),ip nvarchar(20),teller nvarchar(20),server nvarchar(20),result nvarchar(20) )";
con2.Open();
com2.ExecuteNonQuery();
con2.Close();
}

oghab
سه شنبه 08 بهمن 1387, 14:52 عصر
سلام
من SQL Server 2000 دارم. database با چه اسمي؟ چه جدولهايي و چه مشخصاتي ميخواهي؟