2013-06-25 24 views
0

我開始了Windows Forms的新項目。第一頁是UserLogin。在表單加載事件中,我將數據庫中的登錄表導入內存。 我正在使用所有讀取和寫入操作方法存儲的類。錯誤:'classA'在當前上下文中不存在

當我打電話formload事件的類,錯誤來「在目前情況下不列入存在」

我可能會丟失一些參考或headerfilename ..

請提前

幫助 謝謝
using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Linq; 
    using System.Text; 
    using System.Windows.Forms; 
    using System.Configuration; 
    using System.Web; 

    namespace InvestmentAndReturns 
    { 
public partial class UserLogin : Form 
{ 
    public UserLogin() 
    { 
     InitializeComponent(); 
     CenterToScreen(); 
    } 

    public string UserID = null; 
    private string userPass = null; 
    public string UserGroup = null; 
    DataTable UserLoginTable; 
    int logintry = 1; 
    public bool LoginStatus = false; 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     txtUserID.Select(); 

     string cmd = "Select * from UserLogin"; 
     UserLoginTable = DbRdRw.SqlDbRead(cmd, "UserLogin"); 
    } 

DbRdRw:這是 類SqlDbRead:這個被讀取方法

回答

0

我已經在項目文件夾直接粘貼包含該類然後打開解決方案,然後納入項目

看起來你有一些其他的項目包含的DbRdRw定義複製粘貼的源文件 - 這主要是指文件中的namespace聲明將來自較早的項目。

如果您將名稱空間更改爲當前項目InvestmentAndReturns,則可以正常工作。

但是,你爲什麼複製粘貼這個呢?您可以爲您的DbRdRw創建一個庫DLL並引用該DLL。這樣你就可以將源代碼保存在一個地方。

+0

不知道如何使dll 我目前正在學習winforms – Sam

相關問題