Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Good afternoon everyone!
 
I had a question about this error I'm getting on VS 2008, this is what I get when trying to debug my app, I believe its an issue with dsUser trying to define something but I can't tell what it is.
 
This is the error:
 
'dsUser' does not contain a definition for 'tblEmployee' and no extension method 'tblEmployee' accepting a first argument of type 'dsUser' could be found (are you missing a using directive or an assembly reference?)
 
This is what I have in my clsDataLayer.cs page:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
// These are modules that are needed in .Net
using System.Data.OleDb;
using System.Net;
using System.Data;
 
/// <summary>
/// Summary description for clsDataLayer
/// </summary>
public class clsDataLayer
{
    
    public static dsUser VerifyUser(string Database, string UserName, string UserPassword)
    {
        // Dataset dsUser
        dsUser DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA1, sqlDA2;
 
        // tells us we are using Access
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                      "Data Source=" + Database);
 
        // Selects only those with access/authentication
        sqlDA1 = new OleDbDataAdapter("Select * from tblEmployee " +
                                      "where emp_Id like '" + UserName + "' " +
                                      "and emp_Pass like '" + UserPassword + "'", sqlConn);
 
        sqlDA2 = new OleDbDataAdapter("Select * from tblStudent " +
                                      "where Stud_Id like '" + UserName + "' " +
                                      "and Stud_Pass like '" + UserPassword + "'", sqlConn);
 
        // new Dataset dsUser
        DS = new dsUser();
 
        // populates with the userlogin
        sqlDA1.Fill(DS.tblEmployee);
        sqlDA2.Fill(DS.tblStudent);
 
        // Dataset
        return DS;
 
    }
 

    // This function saves the personnel data
    public static bool SaveUser(string Database, string UserName, string UserPassword, string SecurityLevel)
    {
 
        bool recordSaved;
        // Create a new connection
        OleDbTransaction myTransaction = null;
 
        try
        {
            // Database connection (Access here) shows he type etc
            OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                                       "Data Source=" + Database);
            conn.Open();
            OleDbCommand command = conn.CreateCommand();
            string strSQL;
 
            //Here we are doing a TRANSACTION
            myTransaction = conn.BeginTransaction();
            command.Transaction = myTransaction;
 
            // This inserts the data into the database FirstName, etc
            strSQL = "Insert into tblEmployee " +
                     "(UserName, UserPassword, SecurityLevel) values ('" +
                     UserName + "', '" + UserPassword + "', '" + SecurityLevel + "')";
 
            // Sets the command to the strSQL variable
            command.CommandType = CommandType.Text;
            command.CommandText = strSQL;
 
                      
            // Saves the command in memory
            command.ExecuteNonQuery();
 
            // This commits the transaction
            myTransaction.Commit();
 
            // Close the connection to the database
            conn.Close();
            
            recordSaved = true;
        }
        catch (Exception ex)
        {
            // If there is an exception Rollback - do NOT commit the data
            myTransaction.Rollback();
 
            recordSaved = false;
 
        }
 
        return recordSaved;
    }
 
}
 
[edit]Code block added - OriginalGriff[/edit]
Posted 3-May-13 9:24am
Edited 3-May-13 9:28am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The error is pretty explicit:
'dsUser' does not contain a definition for 'tblEmployee' and no extension method 'tblEmployee' accepting a first argument of type 'dsUser' could be found (are you missing a using directive or an assembly reference?)
What this normally means is that your dsUser class (which is what DS is declared as) does not contain a property of method called tblEmployee - it is possible that you meant to use the name as an index, or as a property-of-a-property, or that dsUser is the wrong class altogether. Or possibly, you just forgot to create the property! Laugh | :laugh:
 
Whichever way it is, you need to look at your class and work oput what you did mean to write - because we can't help you without access to your code!
 
[edit]Missed a close bracket - OriginalGriff[/edit]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It's not dsUser who is trying to defined something. Whatever happens, this is always you who it trying or not trying to define something. In this respect, the question makes no sense, but you can easily address the problem if you take responsibility for your own code (and, if this code is written by someone else, please don't tell us about it; either ask this person or assume full responsibility for the code; this is you job).
 
This time, the symbol you did not try to define is tblEmployee. I could be a remnant of some removed code, some artifact of previous mess up. Define it the way you want or remove it.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 245
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 3 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100