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>
Creating a connection to create a database with a process
</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";
System.Diagnostics.Process sqlprocess = new System.Diagnostics.Process ();//Create a process
SqlProcess.StartInfo.FileName = "Osql.exe";//osql a utility that is based on ODBC-driven connection to the server (consult the SQL Help manual)
String str = @ "C:\Program files\microsoft SQL Server\MSSQL\Data";
sqlProcess.StartInfo.Arguments = "-u sa-p sa-d sqltest-i c:\\program Files\\Microsoft SQL Server\\mssql\\data";//Get Boot The parameters of the order
SqlProcess.StartInfo.WindowStyle = system.diagnostics.processwindowstyle.hidden;//The window state of the calling process, hidden as background
Sqlprocess.start ();
Sqlprocess.waitforexit ();
Sqlprocess.close ();
return true;
}
catch (Exception ex)
{
Throw ex;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.