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

  • Home
  • SEARCH
  • 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 329459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:35:25+00:00 2026-05-12T09:35:25+00:00

I am writing a console program in C# and I need to use a

  • 0

I am writing a console program in C# and I need to use a database.

I am looking for very basic tutorials on connecting with and using a db from a C# console program. I haven’t been able to find anything basic enough yet and I hope people here can help me find the info I need. I’ve read the material on MSDN, but MSDN assumes basic knowledge about these things that I am still looking for.

I have created a db within VS Express in my project, created tables, and written some starter records into the tables. I’m trying to find out exactly what each of these things is, and how to determine how to apply them in my project:

SQLConnection

SQLConnection class

SQLCommand

SQLDataAdapter

DataSets

Thanks.

  • 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-12T09:35:26+00:00Added an answer on May 12, 2026 at 9:35 am

    Something like:

    using System.Data;
    using System.Data.SqlClient;
    
    using(SqlConnection connection = new SqlConnection("")){
        SqlCommand command = new SqlCommand(@"
    insert into
        tblFoo (
            col1,
            col2
        ) values (
            @val1,
            @val2
        )",
        connection
        );
    
        SqlParameter param = new SqlParameter("@val1", SqlDbType.NVarChar);
        param.Value = "hello";
    
        command.Parameters.Add(param);
    
        param = new SqlParameter("@val2", SqlDbType.NVarChar);
        param.Value = "there";
    
        command.Parameters.Add(param);
    
        command.ExecuteNonQuery();
        connection.Close();
    }
    

    — Edit:

    Though, of course, when you start doing serious things, I recommend an ORM. I use LLBLGen (it costs money, but most definitely worth it).

    — Edit:

    SqlConnection

    The thing through which you communicate to the database. This will hold the name of the
    server, the username, password, and other misc things.

    SqlCommand

    Something that holds the sql statement you want to send to the server. This may be an ‘update’ or ‘insert’ or ‘select’ or anything. Depending on what it is, you use a different method to execute it, to possible get data back.

    SqlDataAdapter

    A strange one; it’s used specifically to fill a ‘DataSet’. It basically does a bit of work for you, adding the information it finds to the set.

    DataSet

    Not sure how simple you want this. It’s just a collection of returned data, in a table-like format, that you can iterate over. It contains DataTables, because some queries can return more than one table. Typically, though, you’ll only have one table, and you can bind to it, or whatever.

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

Sidebar

Ask A Question

Stats

  • Questions 180k
  • Answers 180k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried this? compilerparams.ReferencedAssemblies.Add(entryasm.Location); May 12, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer select MyDate from MyTable order by case when MyDate is… May 12, 2026 at 4:02 pm
  • Editorial Team
    Editorial Team added an answer The standard program basename does what you want: $ basename… May 12, 2026 at 4:02 pm

Related Questions

I am writing a console program in C#. Is there a way I can
I am writing some small program in C--some log in, log out, create account,
I'm writing a microformats parser in C# and am looking for some refactoring advice.
I am working on making an address book in C# 2008. I need to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.