TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Martijn
NA
6
0
String/object active outside public void
Feb 6 2009 6:10 AM
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]
Reply
Answers (
4
)
C# Language Basics
Send Crystal Report application through C#