Foros del Web » Programación para mayores de 30 ;) » .NET »

C# y mas

Estas en el tema de C# y mas en el foro de .NET en Foros del Web. HOLA, SOY NUEVA EN ESTO DEL FORO Y .NET, ME GUSTARIA SABER COMO PUEDO HACER PARA REALIZAR UNA CONSULTA DE UNA BD EN .NET YA ...
  #1 (permalink)  
Antiguo 08/06/2009, 18:54
 
Fecha de Ingreso: junio-2009
Mensajes: 1
Antigüedad: 14 años, 10 meses
Puntos: 0
C# y mas

HOLA, SOY NUEVA EN ESTO DEL FORO Y .NET, ME GUSTARIA SABER COMO PUEDO HACER PARA REALIZAR UNA CONSULTA DE UNA BD EN .NET YA HABIANDO ESTABLECIDO MI CONEXION A LA BD, ME SERIA DE GRAN AYUDA PUES NO TENGO NI LA MENOR IDEA.

YA QUE AL CONECTARME A UN DATAGRID ME MARCA UN ERROR,

MI CODIGO PARA ESTABLECER LA CONEXION ES EL SIGUIENTE:

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.OracleClient;
using System.IO;
using System.Collections;


namespace bd
{
public partial class Form1 : Form
{
//private OracleCommand commDB;
//private OracleDataReader reader;
private OracleConnection conexion;
private string usuarioadmin;
private string paswdadmin;
private string servidor;
private OracleCommand commDB;
private OracleDataReader reader;
//private string consulta;
//private string ip_serv;
//private string serv;
//private ArrayList origen;
//private ArrayList destino;

public Form1()
{
InitializeComponent();
}

public Form1(string[] args)
{

InitializeComponent();

usuarioadmin = args[0];
paswdadmin = args[1];
servidor = args[2];


}
private Boolean ConexionOracle()
{
try
{
string comunicacion;

comunicacion = "User Id=" + usuarioadmin + ";Password=" + paswdadmin + ";Data Source=" + servidor;

this.conexion = new OracleConnection();
this.conexion.ConnectionString = comunicacion;
this.conexion.Open();
return true;

}
catch (IOException e)
{
Console.WriteLine(" Se perdio la conexión con el Oracle; Se Genero el Error : " + e.Message);
return false;
}
catch (OracleException ex)
{
Console.WriteLine(" Se perdio la conexión con el Oracle; Se Genero el Error : " + ex.Message);
return false;
}

}
private void button1_Click(object sender, EventArgs e)
{

//this.ConexionOracle();
if (ConexionOracle())
{
MessageBox.Show(" SE HA CONECTADO CORRECTAMENTE A LA BASE DE DATOS ");


}



}


DE AHI EN FUERA NO SE QUE MAS HACER PARA PODER VERIFICAR QUE EFECTIVAMENTE ESTE CONECTADO YA QUE NO ME SALEN LAS CONSULTAS, ALGUIEN ME PODRIA AYUDAR? :(
ES URGENTISIMO!!!!!!!


GRACIAS
  #2 (permalink)  
Antiguo 09/06/2009, 11:31
Avatar de HuachoSoft  
Fecha de Ingreso: mayo-2009
Ubicación: Lima - Peru
Mensajes: 8
Antigüedad: 14 años, 11 meses
Puntos: 0
Respuesta: C# y mas

si al hacer conexion.open no te sale ningun error es que ya estas conectada.

ahora, para hacer las consultas debes usar un datareader y tu command. pero antes de hacerlo tienes que validar como están trabajando las tablas en oracle, es decir si es con el paquete generico o estan generando varios paquetes. tambien para mas ayuda, podrias poner el codigo que usas para realizar el select.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:27.