2013-08-29 30 views
0

我在VB中使用了一個使用dll來搜索數據庫的舊應用程序的代碼。你能告訴我怎麼在c#中做到這一點。如何使用c#訪問dll?

Pseek是DLL

Dim SeekForm As New PSeek.cSeek 
      Dim redRow As mscomctl.ListItem 
      Dim succ As Long 
      Try 
       redRow = Nothing 
       succ = SeekForm.CallSeekForm(My.Settings.PSeekConnectionString, "SELECT id,naziv,adresa,broj,vlez,stan,mesto from vSifrarnik where Firmaid = " & My.Settings.curFirma & " and Siftipid=" & SifTipIDUltraCombo.Value, "id,naziv,adresa,broj,vlez,stan,mesto", redRow, 1, , True, False) 
       If Not (redRow) Is Nothing Then 
        SifraIDUltraTextEditor.Text = redRow.Text 
        SifraIDUltraTextEditor.Focus() 
       End If 
      Catch ex As System.Exception 
       System.Windows.Forms.MessageBox.Show(ex.Message) 
      End Try 
+2

'Pseek是dll' Pseek是**不是** dll,它的類可能包含在dll中。只要你在你的項目中包含了對dll的引用,就可以在你的項目中使用該類。C#項目 – SysDragon

回答

0

在項目中添加DLL文件,通過點擊右鍵,然後加入參考和選擇的dll文件。然後在你的代碼類型

using LibraryName; 
+0

我這樣做了,但我似乎無法讓它做與VB代碼一樣的操作,請問'將VB代碼翻譯成C#'? –

+0

使用此在線工具:http://www.developerfusion.com/tools/convert/vb-to-csharp/ – 2013-08-29 13:00:39

+0

向我們展示您迄今爲止擁有的C#代碼。 –