using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class slu1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (execfile())
{
Response.Write("Success");
}
}
}
/// <summary>
/// 創建連接起用進程建立數據庫
/// </summary>
/// <returns></returns>
private bool execfile()
{
try
{
string connStr = "data source=127.0.0.1;user id=sa;passWord=sa;persist security info=false;packet size=4096";
ExecuteSql(connStr, "master", "CREATE DATABASE" + " SqlTest");//調用ExecuteNonQuery()來創建數據庫
System.Diagnostics.Process sqlProcess = new System.Diagnostics.Process();//創建一個進程
sqlProcess.StartInfo.FileName = "osql.exe";//OSQL基於ODBC驅動連接服務器的一個實用工具(可查閱SQL幫助手冊)
//string str = @"C:\Program Files\Microsoft SQL Server\MSSQL\Data";
&n