如何用C#来部署数据库__教程 |
|
日期:2007-5-9 18:49:54 人气:206 [大 中 小] |
|
|
|
{ SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = "Data Source= " + txtServerName.Text + ";" + " User id=" + txtUserName.Text + ";" + " Password=" + txtPassword.Text + "; Initial Catalog=master"; try { sqlConn.Open(); } catch { MessageBox.Show( "Failed to connect to DB!" ); return; } //Create DB using specific file CreateDB( ref sqlConn ); sqlConn.Close(); sqlConn.Dispose(); } private bool ReadSQLFromFile(out string strQuery) { const string strFileName = "DBFile.sql";//Give specific SQL file strQuery = ""; //Init return value if( File.Exists(strFileName) ) { StreamReader sr = File.OpenText(strFileName); strQuery = sr.ReadToEnd(); sr.Close(); return true; |
|
出处:本站原创 作者:佚名 |
|
|