c# 建库 建表的方法谁能帮我写一个类
c# 建库 建表的方法谁能帮我写一个类
------解决方案-------------------- private Boolean CreateDataBase(String name, SqlConnection sqlConnection)
{
String sqlCommandText = "create database " + name;
SqlCommand sqlCommand = new SqlCommand(sqlCommandText, sqlConnection);
try
{
sqlCommand.ExecuteScalar();
}
catch
{
return false;
}
return true;
}
private Boolean CreateTable(String dataBaseName, String tableName, Node NodeConfig, SqlConnection sqlConnection)
{
String sqlCommandText = "use " + dataBaseName;
SqlCommand sqlCommand = new SqlCommand(sqlCommandText, sqlConnection);
sqlCommand.ExecuteScalar();
sqlCommandText = "CREATE TABLE " + tableName;
int n = NodeConfig.Nodes.Count;
String PKs = "";
for (int i = 0; i < n; i++)
{
Node node = NodeConfig.Nodes[i];
String name = node.Property("name").Value;
String dateType = node.Property("dateType").Value;
String prec = node.Property("prec").Value;
String