C# czemu czepia się ConfigurationMenager ?????

0

oto kod
prosze o poradę.
Zadeklarowałem przestrzeń nazw więc nie powinno tak się dziać

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private String connectionString = null;
        private SqlConnection sqlConnection = null;
        private SqlDataAdapter sqlDataAdapter = null;
        private SqlCommandBuilder sqlCommandBuilder = null;
        private DataTable dataTable = null;
        private BindingSource bindingSource = null;
        private String selectQueryString = null;





        public Form1()
        {
            InitializeComponent();

            
        }

        private void pracownicyBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.pracownicyBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.hityFilmoweDataSet);

        }


        private void Form1_Load(object sender, EventArgs e)
        {


            connectionString = ConfigurationManager.AppSettings["connectionString"];
            sqlConnection = new SqlConnection(connectionString);
            selectQueryString = "SELECT * FROM Pracownicy";

            sqlConnection.Open();

            sqlDataAdapter = new SqlDataAdapter(selectQueryString, sqlConnection);
            sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);

            dataTable = new DataTable();
            sqlDataAdapter.Fill(dataTable);
            bindingSource = new BindingSource();
            bindingSource.DataSource = dataTable;

            a.DataSource = bindingSource;

            // if you want to hide Identity column
            a.Columns[0].Visible = false;


            // TODO: This line of code loads data into the 'hityFilmoweDataSet.Pracownicy' table. You can move, or remove it, as needed.
            this.pracownicyTableAdapter.Fill(this.hityFilmoweDataSet.Pracownicy);

        }

        private void button1_Click(object sender, EventArgs e)
        {
        
            
            try
            {
                sqlDataAdapter.Update(dataTable);
            }
            catch (Exception exceptionObj)
            {
                MessageBox.Show(exceptionObj.Message.ToString());
            }



        }

        private void button2_Click(object sender, EventArgs e)
        {
        


            try
            {
               a.Rows.RemoveAt(a.CurrentRow.Index);
               sqlDataAdapter.Update(dataTable);
            }
            catch (Exception exceptionObj)
            {
               MessageBox.Show(exceptionObj.Message.ToString());
            }


        }
    }
}
 
0

Jest kod, to już coś, ale zapomniałeś opisać problemu i zadać pytania.

0

pytanie jest w tytule
Error wyskakuje przy słowie kluczowym ConnectionManager
Czemu?????

sorki configurationManager

0

Idź do wróżki, bo tylko Ty i ona wiecie, jaki to jest error.

0

a moze w tourialu ktoś się pomylił i zamiast

ConfigureSettings dał ConfigureManager bo teraz działą perfekto
pozdoro dla admina:]

error

Error 2 The name 'ConfigurationManager' does not exist in the current context C:\Users\Tomek\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 41 32 WindowsFormsApplication1

0

Błędu nie ma w kodzie, błąd jest w konfiguracji projektu. Dodaj referencję do System.Configuration.
W solution explorer prawym na katalog references->Add reference->Kategoria Assemblies->dwuklik na System.Configuration

1 użytkowników online, w tym zalogowanych: 0, gości: 1