4
Answers

String/object active outside public void

Photo of Martijn

Martijn

16y
3k
1
Hello C# people,

I have a question; how do i get my values outside of the button?

[code]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Xml;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace MySQL_verbinding
{
    public partial class MainFrame : Form
    {
        public MainFrame()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {
            string MyConString = "SERVER=localhost;" +
                "DATABASE=flessensysteem;" +
                "UID=root;" +
                "PASSWORD=1q2w3e;";
            MySqlConnection connection = new MySqlConnection(MyConString);           
        }


        public void get_Click(object sender, EventArgs e)
        {
            MySqlCommand command = connection.CreateCommand();
            MySqlDataReader Reader;
            command.CommandText = "select * from flessen";
            connection.Open();
            Reader = command.ExecuteReader();
            while (Reader.Read())
            {
                string thisrow = "";
                for (int i = 0; i < Reader.FieldCount; i++)
                    thisrow += Reader.GetValue(i).ToString() + ",";
                thisrow += ";";
                listBox1.Items.Add(thisrow);
            }
        }



        public void close_Click(object sender, EventArgs e)
        {
            connection.Close();
        }
}
}[/code]

error:
[code]Error    1    The name 'connection' does not exist in the current context    C:\**\MySQL verbinding\MainFrame.cs    34    36    MySQL verbinding
Error    2    The name 'connection' does not exist in the current context    C:\**\MySQL verbinding\MySQL verbinding\MainFrame.cs    37    13    MySQL verbinding
Error    3    The name 'connection' does not exist in the current context    C:\**\MySQL verbinding\MySQL verbinding\MainFrame.cs    53    13    MySQL verbinding
[/code]

Answers (4)

0
Photo of Prakash Tripathi
NA 21k 2.5m 9y
You may want to explore MVC/ WEB API/ Client side frameworks (angular etc.). As these have become should have skills for .net web developers
0
Photo of viswa a
NA 264 10.9k 9y
ASP.NET is said to be desinging side of web and you have mvs go for it and keep updating thats will do for you.
0
Photo of Vignesh Mani
NA 13.4k 938.4k 9y
MVC and WCF are most important one.
0
Photo of Prasham Sabadra
NA 17.6k 1.2m 9y
Hi Rohan,
 
MVC is key technology, the use of both the technologies are for different requirements. But both are mostly require to use together.
 
Lets have hands on MVC first and then try WCF. 
0
Photo of Vignesh Mani
NA 13.4k 938.4k 9y
Asp.NET MVC 6 is new. You should learn MVC.
0
Photo of Upendra Pratap Shahi
NA 13.3k 861.7k 9y
In now days both are important for carrier growth.
 
and have knowledge of
 
Angular JS, node.js, KnockOut js
Entity Framework
WCF Services
WPF
WebAPI
 
0
Photo of Rohan Gupta
NA 442 44.8k 9y
ok Mr. Prasham Sabadra but wcf in best or mvc for me.
0
Photo of Prasham Sabadra
NA 17.6k 1.2m 9y
Hi Rohan,
 
Please have hands on asp.net mvc. MVC 5 is already there and asp.net vNext is in preview.
 
Lets have in depth understanding of MVC framework and then there are lots of supporting technologies like
 
Client side frameworks Angular JS, node.js, KnockOut js
Entity Framework
WCF Services
WPF
WebApis
 
Please let me if some more clarification required.
 
0
Photo of Rohan Gupta
NA 442 44.8k 9y
which type of new technologies 
0
Photo of Vignesh Mani
NA 13.4k 938.4k 9y
Hi first know well basic concept in-depth and learn new technologies as well as touch with technical people in different organizations.