第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C#與SQL2005數(shù)據(jù)部署安裝問題

C#與SQL2005數(shù)據(jù)部署安裝問題

小唯快跑啊 2018-12-06 18:59:01
在網(wǎng)站找到了實現(xiàn)方法,但是打包后的EXE文件無法安裝數(shù)據(jù)庫,小弟不才,敬請大俠指教! 我的實現(xiàn)代碼: private void ExecuteSql(string conn, string DatabaseName, string Sql)??????? {??????????? SqlConnection mySqlConnection = new SqlConnection(conn);??????????? SqlCommand Command = new SqlCommand(Sql, mySqlConnection);??????????? mySqlConnection.Open();??????????? mySqlConnection.ChangeDatabase(DatabaseName);??????????? try??????????? {??????????????? Command.ExecuteNonQuery();??????????? }??????????? finally??????????? {??????????????? //close Connection? ??????????????? mySqlConnection.Close();??????????? }??????? } public override void Install(System.Collections.IDictionary stateSaver)??????? {??????????? base.Install(stateSaver); ??????????? // ------------------------建立數(shù)據(jù)庫------------------------------------------------- ??????????? try??????????? {??????????????? string connstr = String.Format("data source={0};user id={1};password={2};persist security info=false;packet size=4096", Context.Parameters["server"], Context.Parameters["user"], Context.Parameters["pwd"]);??????????????? //'根據(jù)輸入的數(shù)據(jù)庫名稱建立數(shù)據(jù)庫? ??????????????? ExecuteSql(connstr, "master", "CREATE DATABASE " + Context.Parameters["dbname"]);??????????????? //'調用osql執(zhí)行腳本? ??????????????? Process sqlprocess = new System.Diagnostics.Process();??????????????? sqlprocess.StartInfo.FileName = "osql.exe ";??????????????? sqlprocess.StartInfo.Arguments = String.Format(" -U {0} -P {1} -d {2} -i {3}ACM618DeviceInfo.sql", Context.Parameters["user"], Context.Parameters["pwd"], Context.Parameters["dbname"], Context.Parameters["targetdir"]);??????????????? sqlprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;??????????????? sqlprocess.Start();??????????????? sqlprocess.WaitForExit(); // '等待執(zhí)行??????????????? sqlprocess.Close(); ??????????????? //'刪除腳本文件??????????????? FileInfo sqlfileinfo = new FileInfo(String.Format("{0}ACM618DeviceInfo.sql", Context.Parameters["targetdir"])); ??????????????? if (sqlfileinfo.Exists)??????????????? {??????????????????? sqlfileinfo.Delete();??????????????? }??????????? }??????????? catch (Exception ex)??????????? {??????????????? throw ex;??????????? }??????? } 安裝程序時提示的錯誤是: 在建立與服務器的連接時出錯。在連接到 SQL Server 2005 時,在默認的設置下 SQL Server 不允許進行遠程連接可能會導致此失敗。 (provider: SQL 網(wǎng)絡接口, error: 25 - 連接字符串無效) 請問我程序中寫的是哪個字符串出問題了?? 我是剛剛注冊的新手,分不多··給個意思···多多原諒!
查看完整描述

3 回答

?
慕后森

TA貢獻1802條經(jīng)驗 獲得超5個贊

將這個字串打出來復制到連接管理器中試一下

查看完整回答
反對 回復 2019-01-21
?
揚帆大魚

TA貢獻1799條經(jīng)驗 獲得超9個贊

如果你的數(shù)據(jù)庫不是SQL EXPRESS,就應該不是遠程連接的問題

檢查一下你的連接字符串的幾個參數(shù)是否正確傳遞,是否有對應安裝界面的文本框輸入

查看完整回答
反對 回復 2019-01-21
  • 3 回答
  • 0 關注
  • 325 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號