using MySql.Data.MySqlClient;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] registro;
//List<string> list = new List<string>();
ArrayList list = new ArrayList();
string connStr = "Server=localhost;Database=test;Uid=root;Pwd=";
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
string commandStr = "SELECT usr_id, usr_nick FROM users";
MySqlCommand command = new MySqlCommand(commandStr, conn);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
registro = new string[2];
registro[0] = reader.GetString("usr_id");
registro[1] = reader.GetString("usr_nick");
//registro[2] = reader.GetString(2);
//registro[3] = reader.GetString(3);
//Se agrega el registro a la lista
list.Add(registro);
}
//Se cierra el Reader
reader.Close();
//Se cierra la conexión
conn.Close();
Console.WriteLine("sdf");
Console.ReadLine();
}
}
}
viernes, 11 de septiembre de 2009
c# conexion MySQL
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario