Click here to Skip to main content
15,881,709 members
Home / Discussions / C#
   

C#

 
AnswerRe: Size of column name Pin
Eddy Vluggen21-Apr-09 23:41
professionalEddy Vluggen21-Apr-09 23:41 
General[Message Deleted] Pin
hkjghkj121-Apr-09 23:50
hkjghkj121-Apr-09 23:50 
GeneralRe: Size of column name Pin
Eddy Vluggen21-Apr-09 23:56
professionalEddy Vluggen21-Apr-09 23:56 
General[Message Deleted] Pin
hkjghkj122-Apr-09 0:02
hkjghkj122-Apr-09 0:02 
GeneralRe: Size of column name Pin
Henry Minute22-Apr-09 0:11
Henry Minute22-Apr-09 0:11 
General[Message Deleted] Pin
hkjghkj122-Apr-09 0:26
hkjghkj122-Apr-09 0:26 
GeneralRe: Size of column name Pin
Skymir23-Apr-09 3:23
Skymir23-Apr-09 3:23 
QuestionMy Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd21-Apr-09 23:20
professionalVimalsoft(Pty) Ltd21-Apr-09 23:20 
Good Afternoon All

As you know in South Africa today is a Election day, i think my ado.net code went to the Elections tooo

i have this code in my DAL

public DataSet Lis_Databases(String DB)
        {

            Strcon = GetConnectionString(DB);


            con = new SqlConnection(Strcon);

            cmdselect = new SqlCommand();

            cmdselect.CommandText = "[dbo].[sp_ListDatabasesOfType_Booking]";

            cmdselect.CommandType = CommandType.StoredProcedure;

            cmdselect.Connection = con;

            da = new SqlDataAdapter();

            da.SelectCommand = cmdselect;

            DataSet ds = new DataSet();

            try
            {
                con.Open();

                da.Fill(ds);
            }
            catch (SqlException)
            {
                throw;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }

            return ds;

        }


and i call this code in my BLL like this

public DataSet Lis_Databases(String DB)
        {
            DAL.DAL obj = new DAL.DAL();

            DataSet ds = new DataSet();

            try
            {
                ds = obj.Lis_Databases(DB);
            }
            catch (SqlException)
            {   
                throw;
            }
            finally
            {

                obj = null;
            }
            return ds;
           
        }


And call use it like this in my PL(Presention Layer)

private void List_Databases_Grid()
    {
        
            BLL.BLL obj = new BLL.BLL();
        
            DataSet ds = new DataSet();

        try
        {

            ds = obj.Lis_Databases(Convert.ToString(Session["ActiveDatabase"]));

            if (ds.Tables[0].Rows.Count > 0)
            {
                GridView_Database_list.DataSource = ds;

                GridView_Database_list.DataBind();
            }
            else
            {
                lblMessage.Text = "No Booking Database Avaiable,Create one";
                lblMessage.Visible = true;
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
        catch (SqlException ex)
        {
            lblMessage.Visible = true;
            lblMessage.Text = "The List cannot be Binded, Please Contact ITS" + ex.Message;
            lblMessage.ForeColor = System.Drawing.Color.Red;
        }
        finally
        {
            obj = null;
        }

    }


when my code Comes to this line
if (ds.Tables[0].Rows.Count > 0)
           {


The evualuation, it passes and that mean records had been returned, now when it gets to this line

GridView_Database_list.DataSource = ds;


it says

Object reference not set to an instance of an object.

i have Initialized the Dataset everywhere as you can see above

what have i done wrong?

You can still Comment on my Error handling

Thank you

Vuyiswa Maseko

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: My Ado.Net code is on a Public Holiday Pin
Mbah Dhaim21-Apr-09 23:31
Mbah Dhaim21-Apr-09 23:31 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd21-Apr-09 23:36
professionalVimalsoft(Pty) Ltd21-Apr-09 23:36 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Greg Chelstowski21-Apr-09 23:46
Greg Chelstowski21-Apr-09 23:46 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd22-Apr-09 0:00
professionalVimalsoft(Pty) Ltd22-Apr-09 0:00 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Eddy Vluggen21-Apr-09 23:48
professionalEddy Vluggen21-Apr-09 23:48 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd21-Apr-09 23:58
professionalVimalsoft(Pty) Ltd21-Apr-09 23:58 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Mbah Dhaim21-Apr-09 23:54
Mbah Dhaim21-Apr-09 23:54 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd22-Apr-09 0:02
professionalVimalsoft(Pty) Ltd22-Apr-09 0:02 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Mbah Dhaim22-Apr-09 0:10
Mbah Dhaim22-Apr-09 0:10 
GeneralRe: My Ado.Net code is on a Public Holiday Pin
Vimalsoft(Pty) Ltd22-Apr-09 0:13
professionalVimalsoft(Pty) Ltd22-Apr-09 0:13 
QuestionHow to add Ticks to an axis using nPlot and c# Pin
Mostrich21-Apr-09 22:59
Mostrich21-Apr-09 22:59 
QuestionIdentify the message end Pin
yesu prakash21-Apr-09 22:59
yesu prakash21-Apr-09 22:59 
AnswerRe: Identify the message end Pin
Rob Philpott21-Apr-09 23:13
Rob Philpott21-Apr-09 23:13 
Question[Message Deleted] Pin
girishsatya21-Apr-09 22:47
girishsatya21-Apr-09 22:47 
AnswerRe: DLL creating Pin
Rob Philpott21-Apr-09 22:49
Rob Philpott21-Apr-09 22:49 
GeneralRe: DLL creating Pin
yesu prakash21-Apr-09 23:04
yesu prakash21-Apr-09 23:04 
AnswerRe: DLL creating Pin
DaveyM6921-Apr-09 23:01
professionalDaveyM6921-Apr-09 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.