Question Locked

c# connection to odbc driver no output

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm using Visual Web Developer to develop an online system that can read from my db2 database. This code is in C# and after eliminating all the errors, there's no output.
Could anybody tell me why? And how do I get it to display the output in my html website?

Thank you so so much

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.Odbc;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString =
"DSN=infofyp;" +
"UID=db2admin;" +
"PWD=palmolive";
IDbConnection dbcon;
dbcon = new OdbcConnection (connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();

//connecting to the table info_db2

string sql =
"SELECT p_id " +
"FROM deepa.info";

dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while (reader.Read()) {
string Identification = (string) reader ["p_id"];
Console.WriteLine ("Indentification: " + Identification);
}

//cleaning up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}

}

1 reply

This discussion is closed to new replies.