Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6825711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:03:53+00:00 2026-05-26T22:03:53+00:00

I have this code here: public class clsDataLayer { // This function saves the

  • 0

I have this code here:

public class clsDataLayer
{
    // This function saves the personnel data 
    public static bool SavePersonnel(string Database, string FirstName, string LastName,
                                     string PayRate, string StartDate, string EndDate)
    {

        bool recordSaved;

        try
        {
            // Retrieving information 
            OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
                                                       "Data Source=" + Database);
            conn.Open();
            OleDbCommand command = conn.CreateCommand();
            string strSQL;
            // Inserting information into the table 
            strSQL = "Insert into tblPersonnel " +
                     "(FirstName, LastName, PayRate, StartDate, EndDate) values ('" +
                     FirstName + "', '" + LastName + "', " + PayRate + ", '" + StartDate +
                    "', '" + EndDate + "')";
            // Gets the statement to execute at the data source 
            command.CommandType = CommandType.Text;
            command.CommandText = strSQL;
            // Executes the SQL statement and returns the number of rows 
            command.ExecuteNonQuery();
            // Closes the connection to the data source 
            conn.Close();
            recordSaved = true;
        }
        catch (Exception)
        {
            recordSaved = false;

        }

        return recordSaved;
    }


    // This function gets the user activity from the tblUserActivity 
    public static dsUserActivity GetUserActivity(string Database)
    {
        // States the classes used 
        dsUserActivity DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        // Defines sqlConnclass and what each will consist of 
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);

        // Defines sqlDA and what each will consist of 
        sqlDA = new OleDbDataAdapter("select * from tblUserActivity", sqlConn);

        // Defines DS and what each will consist of 
        DS = new dsUserActivity();

        // Outputs the results from the information gathered 
        sqlDA.Fill(DS.tblUserActivity);

        // Starts over for a new user 
        return DS;
    }

    // This function saves the user activity 
    public static void SaveUserActivity(string Database, string FormAccessed)
    {
        // Defines the connection to the database 
        OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);
        conn.Open();
        OleDbCommand command = conn.CreateCommand();
        string strSQL;

        strSQL = "Insert into tblUserActivity (UserIP, FormAccessed) values ('" +
            GetIP4Address() + "', '" + FormAccessed + "')";

        command.CommandType = CommandType.Text;
        command.CommandText = strSQL;
        command.ExecuteNonQuery();
        conn.Close();
    }

    // This function gets the IP Address 
    public static string GetIP4Address()
    {
        string IP4Address = string.Empty;

        foreach (IPAddress IPA in
                    Dns.GetHostAddresses(HttpContext.Current.Request.UserHostAddress))
        {
            if (IPA.AddressFamily.ToString() == "InterNetwork")
            {
                IP4Address = IPA.ToString();
                break;
            }
        }

        if (IP4Address != string.Empty)
        {
            return IP4Address;
        }

        foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
        {
            if (IPA.AddressFamily.ToString() == "InterNetwork")
            {
                IP4Address = IPA.ToString();
                break;
            }
        }

        return IP4Address;
    }




    public clsDataLayer()
    {

    }



    public static dsPersonnel GetPersonnel(string p)
    {
        throw new NotImplementedException();
    }
}

I need to add this code but everytime I do I get an error that says No overload for method ‘GetPersonnel’ takes ‘1’ arguments

// This function gets the user activity from the tblPersonnel 
    public static dsPersonnel GetPersonnel(string Database, string strSearch)
    {
        dsPersonnel DS;
        OleDbConnection sqlConn;
        OleDbDataAdapter sqlDA;

        //create the connection string  
        sqlConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
        "Data Source=" + Database);

        string query;
        if (strSearch == "" || strSearch.Trim().Length == 0)
        {
            query = "SELECT * from tblPersonnel";
        }
        else
        {
            query = "select * from tblPersonnel where LastName = '" + strSearch + "'";
        }


        // Defines sqlDA and what each will consist of 
        sqlDA = new OleDbDataAdapter("select * from tblPersonnel", sqlConn);

        // Defines DS and what each will consist of 
        DS = new dsPersonnel();

        // Outputs the results from the information gathered 
        sqlDA.Fill(DS.tblPersonnel);

        // Starts over for a new user 
        return DS;
    }

    // This function saves the user activity 
    public static void SavePersonnel(string Database, string FormAccessed)
    {
        // Defines the connection to the database 
        OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Database);
        conn.Open();
        OleDbCommand command = conn.CreateCommand();
        string strSQL;

        strSQL = "Insert into tblPersonnel (UserIP, FormAccessed) values ('" +
            GetIP4Address() + "', '" + FormAccessed + "')";

        command.CommandType = CommandType.Text;
        command.CommandText = strSQL;
        command.ExecuteNonQuery();
        conn.Close();

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:03:53+00:00Added an answer on May 26, 2026 at 10:03 pm

    It looks like you’re defining

    public static dsPersonnel GetPersonnel
    

    twice in the same class. I suspect you are REPLACING the single-arg version with the two-arg version but somewhere you’re still calling the single-arg version.

    I know you’re not asking for this sort of input, but I can’t help myself…

    You should wrap your OleDbConnections in a using block to make sure they get closed like so:

    using (OleDbConnection conn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" +   
            "Data Source=" + Database))
    {
        conn.Open();
        ...
    {
    

    Not sure where your strSearch data is coming from, but you’re setting yourself up for a nasty SQL Injection attack with this line:

    query = "select * from tblPersonnel where LastName = '" + strSearch + "'";    
    

    you should use SQL parameters or a stored procedure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class called SiteAsyncDownload.cs Here's the code: public class SiteAsyncDownloader { WebClient
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
I have a partial class like this public partial class ABC { public string
Suppose I have following code: public class CBase: AbstractC,IRenderable { //code here } public
I have this code: package graphics { import flash.display.Sprite; import flash.events.*; public class Ball
I have this code(class in class) in java (andorid) public class History extends Activity
Hi All I have the following code: enter code here public class XMPPClient extends
I have this code snippet import java.util.ArrayList; import java.util.List; public class AssertTest { public
I have this code: public class Home extends Activity{ @Override public void onCreate(Bundle savedInstanceState)
I have this method public static List<Contact> Load(string filename) { if (!File.Exists(filename)) { throw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.