日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
檢測局域網(wǎng)電腦是否有安裝SQLServer數(shù)據(jù)庫

本文主要介紹如何檢測局域網(wǎng)中的電腦是否有安裝SQL Server數(shù)據(jù)庫,并將其列出的方法。接下來我們就開始介紹這一過程的實現(xiàn)。

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于成都網(wǎng)站設計、網(wǎng)站建設、外貿(mào)網(wǎng)站建設、東西湖網(wǎng)絡推廣、微信小程序、東西湖網(wǎng)絡營銷、東西湖企業(yè)策劃、東西湖品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供東西湖建站搭建服務,24小時服務熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com

引用SQL DMO組件。

 
 
 
  1. //取得本局域網(wǎng)內(nèi)所有可用sql服務器名
  2. cmbServer.Items.Clear();
  3. try
  4. {
  5. SQLDMO.Application app = new SQLDMO.ApplicationClass();
  6. SQLDMO.NameList list = app.ListAvailableSQLServers();
  7. int iCount = list.Count;
  8. for(int i = 0; i < iCount; i ++)
  9. {
  10. string sTemp = list.Item(i);
  11. if(sTemp != null)
  12. cmbServer.Items.Add(sTemp);
  13. }
  14. }
  15. catch
  16. {
  17. //如果取得SQLDMO組件出錯, 則默認把本機名寫進去
  18. MessageBox.Show("無法取得服務器列表,可能是缺少SDLDMO.DLL!");
  19. cmbServer.Items.Add(System.Net.Dns.GetHostName());
  20. }

為什么我用panyee(快樂王子)的那個例子一直出現(xiàn)“無法取得服務器列表,可能是缺少SDLDMO.DLL”,我有這個文件啊!

如果用“http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=BCEAADFB-CFF3-4804-B3B3-6C7D6488982B”里的例子也不行會出現(xiàn)以下信息:

"未處理的“System.InvalidCastException”類型的異常出現(xiàn)在WindowsApplication1.exe 中。

其他信息:接口SQLDMO.NameList 的QueryInterface 失敗。

怎么回事,請高手幫幫忙??!

***,你的SQL Server數(shù)據(jù)庫版本不夠。如果要使用SQLDMO.DLL就要去下載SQL sp2.

第二,如果你想列出局域網(wǎng)內(nèi)的所有的SQl server。建議你用Sql server自帶的 isql.exe 這個文件只要是sql server 6.5以上就可以了。

下面是源碼:

 
 
 
  1. string fileName = "C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\isql.exe";
  2. if(System.IO.File.Exists(fileName))
  3. {
  4. System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(fileName,"-L");
  5. processStartInfo.UseShellExecute = false;
  6. processStartInfo.CreateNoWindow = true;
  7. processStartInfo.RedirectStandardOutput = true;
  8. processStartInfo.RedirectStandardError = true;
  9. System.Diagnostics.Process process = System.Diagnostics.Process.Start(processStartInfo);
  10. process.WaitForExit();
  11. cboServerList.Items.Clear();
  12. int line = 1;
  13. string server = null;
  14. while(process.StandardOutput.Peek() > -1)
  15. {
  16. server = process.StandardOutput.ReadLine().Trim();
  17. line +=1;
  18. if ( line > 6)
  19. {
  20. cboServerList.Items.Add(server);
  21. }
  22. server = null;
  23. }
  24. }
  25. cboServerList.Items.Remove(System.Environment.MachineName);
  26. cboServerList.Items.Add("localhost");

cboServerList是一個ComoBox。

你可以現(xiàn)在cmd中輸入isql.exe -? 看看參數(shù)序列中有沒有你想要的。

至于說列出局域網(wǎng)內(nèi)的SQL Server數(shù)據(jù)庫要輸入 isql -L就可以了。

 
 
 
  1. private void cmbDatabase_Enter(object sender, System.EventArgs e)
  2. {
  3. //取得某服務器上的各個表名
  4. string strServer = cmbServer.Text;
  5. string strUid = txtUid.Text;
  6. if(strServer.Trim() != "" && strUid.Trim() != "")
  7. {
  8. string strPwd = txtPwd.Text;
  9. string strConn = "server=" + strServer + ";database=master;uid=" + strUid + ";pwd=" + strPwd;
  10. SqlConnection conn = null;
  11. try
  12. {
  13. conn = new SqlConnection(strConn);
  14. string strSQL = "select * from sysdatabases order by dbid";
  15. SqlDataAdapter cmd = new SqlDataAdapter(strSQL, conn);
  16. DataSet ds = new DataSet();
  17. cmd.Fill(ds, "Databases");
  18. cmbDatabase.Items.Clear();
  19. for(int i = 0; i < ds.Tables["Databases"].Rows.Count; i ++)
  20. {
  21. string strDb = ds.Tables["Databases"].Rows[i]["name"].ToString();
  22. cmbDatabase.Items.Add(strDb);
  23. }
  24. }
  25. catch(Exception ex)
  26. {
  27. MessageBox.Show(ex.ToString());
  28. }
  29. finally
  30. {
  31. if(conn.State == ConnectionState.Open)
  32. conn.Close();
  33. }
  34. }
  35. this.Cursor = Cursors.Default;
  36. }

 這樣,我們就能檢測到局域網(wǎng)內(nèi)是否安裝有SQL Server數(shù)據(jù)庫,并能將其列出了。本文就介紹到這里,希望能對您有所幫助。


新聞名稱:檢測局域網(wǎng)電腦是否有安裝SQLServer數(shù)據(jù)庫
文章路徑:http://www.5511xx.com/article/cceiijo.html