Click here to Skip to main content
13,000,017 members (47,109 online)
Rate this:
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
        // 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;
            // Database connection (Access here) shows he type etc
            OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                                       "Data Source=" + Database);
            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
            // This commits the transaction
            // Close the connection to the database
            recordSaved = true;
        catch (Exception ex)
            // If there is an exception Rollback - do NOT commit the data
            recordSaved = false;
        return recordSaved;

[edit]Code block added - OriginalGriff[/edit]
Posted 3-May-13 8:24am
Updated 3-May-13 8:28am
Rate this: bad
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:

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]
Rate this: bad
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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 3 May 2013
Copyright © CodeProject, 1999-2017
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