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 360457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:29:27+00:00 2026-05-12T12:29:27+00:00

I am trying to build my hello-world program in LINQ. While executing the following

  • 0

I am trying to build my hello-world program in LINQ.

While executing the following code:

(This is my LINQ to SQL class which is generated by VS2008.)

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace LINQ_to_SQL_Test
{
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Data;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Linq;
    using System.Linq.Expressions;
    using System.ComponentModel;
    using System;


    [System.Data.Linq.Mapping.DatabaseAttribute(Name="LINQ_Test")]
    public partial class PersonDataContext : System.Data.Linq.DataContext
    {

        private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertPerson(Person instance);
    partial void UpdatePerson(Person instance);
    partial void DeletePerson(Person instance);
    #endregion

        public PersonDataContext() : 
                base(global::LINQ_to_SQL_Test.Properties.Settings.Default.LINQ_TestConnectionString, mappingSource)
        {
            OnCreated();
        }

        public PersonDataContext(string connection) : 
                base(connection, mappingSource)
        {
            OnCreated();
        }

        public PersonDataContext(System.Data.IDbConnection connection) : 
                base(connection, mappingSource)
        {
            OnCreated();
        }

        public PersonDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
                base(connection, mappingSource)
        {
            OnCreated();
        }

        public PersonDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
                base(connection, mappingSource)
        {
            OnCreated();
        }

        public System.Data.Linq.Table<Person> Persons
        {
            get
            {
                return this.GetTable<Person>();
            }
        }
    }

    [Table(Name="dbo.Person")]
    public partial class Person : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private int _ID;

        private System.Nullable<int> _IDRole;

        private string _LastName;

        private string _FirstName;

    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIDChanging(int value);
    partial void OnIDChanged();
    partial void OnIDRoleChanging(System.Nullable<int> value);
    partial void OnIDRoleChanged();
    partial void OnLastNameChanging(string value);
    partial void OnLastNameChanged();
    partial void OnFirstNameChanging(string value);
    partial void OnFirstNameChanged();
    #endregion

        public Person()
        {
            OnCreated();
        }

        [Column(Storage="_ID", DbType="Int NOT NULL", IsPrimaryKey=true)]
        public int ID
        {
            get
            {
                return this._ID;
            }
            set
            {
                if ((this._ID != value))
                {
                    this.OnIDChanging(value);
                    this.SendPropertyChanging();
                    this._ID = value;
                    this.SendPropertyChanged("ID");
                    this.OnIDChanged();
                }
            }
        }

        [Column(Storage="_IDRole", DbType="Int")]
        public System.Nullable<int> IDRole
        {
            get
            {
                return this._IDRole;
            }
            set
            {
                if ((this._IDRole != value))
                {
                    this.OnIDRoleChanging(value);
                    this.SendPropertyChanging();
                    this._IDRole = value;
                    this.SendPropertyChanged("IDRole");
                    this.OnIDRoleChanged();
                }
            }
        }

        [Column(Storage="_LastName", DbType="VarChar(50)")]
        public string LastName
        {
            get
            {
                return this._LastName;
            }
            set
            {
                if ((this._LastName != value))
                {
                    this.OnLastNameChanging(value);
                    this.SendPropertyChanging();
                    this._LastName = value;
                    this.SendPropertyChanged("LastName");
                    this.OnLastNameChanged();
                }
            }
        }

        [Column(Storage="_FirstName", DbType="VarChar(50)")]
        public string FirstName
        {
            get
            {
                return this._FirstName;
            }
            set
            {
                if ((this._FirstName != value))
                {
                    this.OnFirstNameChanging(value);
                    this.SendPropertyChanging();
                    this._FirstName = value;
                    this.SendPropertyChanged("FirstName");
                    this.OnFirstNameChanged();
                }
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
#pragma warning restore 1591

This is my hand-coded driver program:

class Program
    {
        static void Main(string[] args)
        {
            PersonDataContext dc = new PersonDataContext("LINQ_TestConnectionString");

            Person person = new Person();
            person.ID = 4;
            person.IDRole = 1;
            person.FirstName = "aaa";
            person.LastName = "bbb";

            dc.Persons.InsertOnSubmit(person);
            dc.SubmitChanges();
        }
    }

I am getting the following error message from SQL Server.

A network-related or instance-specific error occurred while 
establishing a connection to SQL Server. The server was not found 
or was not accessible. Verify that the instance name is correct 
and that SQL Server is configured to allow remote connections. 
(provider: Named Pipes Provider, error: 40 - Could not open a 
connection to SQL Server)

How can I solve the problem?

  • 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-12T12:29:27+00:00Added an answer on May 12, 2026 at 12:29 pm

    You’re passing the string literal "LINQ_TestConnectionString" into the constructor – so it’s treating that as the connection string itself. That’s not the connection string, it’s just the name of the connection string setting.

    The the parameterless constructor – that will automatically use the LINQ_TestConnectionString setting:

    PersonDataContext dc = new PersonDataContext();
    

    Alternatively, pass in a real connection string.

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • 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 The error message you quote comes from Visual C++, so… May 12, 2026 at 9:20 pm
  • Editorial Team
    Editorial Team added an answer Ensure you have a MIME type added for the .gz… May 12, 2026 at 9:20 pm
  • Editorial Team
    Editorial Team added an answer Your RPROMPT messes up for me on Ubuntu. Since zsh… May 12, 2026 at 9:20 pm

Related Questions

I'm trying to build a hello world using GTK, which includes the line: #include
Hello there and Merry Christmas !!! I am new to WPF and I am
Preamble So, this question has already been answered, but as it was my first
I am trying to follow examples given in various places for D apps. Generally

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.