Click here to Skip to main content
16,019,055 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            string connetionString = null; 
            SqlConnection connection ; 
            SqlDataAdapter adapter ; 
            DataSet ds = new DataSet(); 
            int i = 0;
            connetionString = NULL;
            connection = new SqlConnection(connetionString); 
            try { 
                connection.Open();
                adapter = new SqlDataAdapter("select *from New", connection); 
                adapter.Fill(ds); 
                connection.Close(); 
                for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { 
                    MessageBox.Show (ds.Tables[0].Rows[i].ItemArray[0].ToString()); 
                } 
            } 
            catch (Exception ex) { 
                MessageBox.Show(ex.ToString()); 
            } 
        }
    }
}
Posted
Updated 8-Oct-15 2:59am
v2
Comments
ZurdoDev 8-Oct-15 8:31am    
Because whatever you are showing is NULL.

What exactly is your question?

1 solution

C#
connetionString = NULL;
connection = new SqlConnection(connetionString);

First, this would not even compile as C# is case sensitive and null keyword is lower case.
Second, isn't there something that disturbs you in these two lines?
Third, why nost just starting a debug session and see what is going on?
 
Share this answer
 
v2
Comments
BillWoodruff 8-Oct-15 22:43pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900