Hello guys this is kind of crazy to ask but i need to know where to locate sqlDataAdapter, sqlConnectio, and datagrid i have looked all the tookbox all i have under data: is datagrdview,dataset, blindingnavigator, pointer, and bindingsource do anyone know where to find the listed item above please and thanks in advance.
oh sorry i'm using visual studio 2008 :)

Recommended Answers

All 9 Replies

Hello guys this is kind of crazy to ask but i need to know where to locate sqlDataAdapter, sqlConnectio, and datagrid i have looked all the tookbox all i have under data: is datagrdview,dataset, blindingnavigator, pointer, and bindingsource do anyone know where to find the listed item above please and thanks in advance.
oh sorry i'm using visual studio 2008 :)

Classes SqlDataAdapter, Sqlconnection ... are classes having no user-interface; located at System.Data.SqlClient namespace.

DataGrid was a name of class and now it is know as DataGridView class - having user-interface and that's why it is called control.

Hello guys this is kind of crazy to ask but i need to know where to locate sqlDataAdapter, sqlConnectio, and datagrid i have looked all the tookbox all i have under data: is datagrdview,dataset, blindingnavigator, pointer, and bindingsource do anyone know where to find the listed item above please and thanks in advance.
oh sorry i'm using visual studio 2008 :)

i think you are migrating from VS 2003 to 2008, those things are no longer available as toolbox items but you can access them using the code page.

Something far away your question but I need to share it with you.
Show the toolbox IFF (if and only if) you need it, because every switch from document to document i.e aspx to aspx.cs to .asmx VS initializes the toolbox (and it slows down the VS) close it and when you need it open it Ctr (X + W)

Ok thanks for that info @Ramy Mahrous this is what i have and i'm still having problem with the highlighted below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WorkEasy1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            string select = "SELECT * FROM ClientDB";

            DataSet ds = new DataSet();

            this.[B]sqlConnection[/B].Open();

            this.[B]sqlDataAdapter[/B] = new [B]SqlDataAdapter[/B](select, sqlConnection1);

            this.[B]sqlDataAdapter[/B].Fill(ds, "ClientDB");

            if (ds.Tables["ClientDB"].Rows.Count == 0)
            {

                MessageBox.Show("There are no DB.");

            }

            else
            {

                this.dataGrid.SetDataBinding(ds, "ClientDB");

            }

            this.[B]sqlConnection[/B].Close();
        }
    }
}

what else do i need to add please and thanks

and no i'm not i installed VS 2008

Ramy is like this, he says something and runs away :D

Thank you Cman :)
Thank you too Serkan :)
All what you need, Cman is to identify sqlDataAdapter, and sqlConnection as global variables <- WHY?!
Because at VS 2003 days, those were components like OpenFileDialog and SaveFileDialog and they were identified globally but they (VS team at MSFT) enhanced ADO.NET architecture and removed those components and they became native classes
so modify your code to

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WorkEasy1
{
    public partial class Form2 : Form
    {
#region Global Variables
SqlConnection sqlConnection = new SqlConnection("Your Connection String");
SqlDataAdapter sqlDataAdapter;
#endregion
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            string select = "SELECT * FROM ClientDB";

            DataSet ds = new DataSet();

            this.sqlConnection.Open();

            this.sqlDataAdapter = new SqlDataAdapter(select, sqlConnection1);

            this.sqlDataAdapter.Fill(ds, "ClientDB");

            if (ds.Tables["ClientDB"].Rows.Count == 0)
            {

                MessageBox.Show("There are no DB.");

            }

            else
            {

                this.dataGrid.SetDataBinding(ds, "ClientDB");

            }

            this.sqlConnection.Close();
        }
    }
}

thanks again guys for your input one last thing on this..i'm getting this error on the same below
Error 1 'System.Windows.Forms.DataGridView' does not contain a definition for 'SetDataBinding' and no extension method 'SetDataBinding' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?)

And this is where the flag is coming from in BOLD
do i need to add SetDataBinding as in a global variable as well
like this

SqlConnection sqlConnection = new SqlConnection("Your Connection String");
SqlDataAdapter sqlDataAdapter;
//SetDataBinding SetDataBinging;

private void Form2_Load(object sender, EventArgs e)
        {
           
            this.testDBTableAdapter.Fill(this.clientDBDataSet.testDB);
            string select = "SELECT * FROM ClientDB";

            DataSet ds = new DataSet();

            this.sqlConnection.Open();

            this.sqlDataAdapter = new SqlDataAdapter(select, sqlConnection);

            this.sqlDataAdapter.Fill(ds, "ClientDB");

            if (ds.Tables["ClientDB"].Rows.Count == 0)
            {

                MessageBox.Show("There are no DB.");

            }

            else
            {

                this[B].dataGridView.SetDataBinding[/B](ds, "ClientDB");
                          

            }

            this.sqlConnection.Close();
        }

Your error says what it says, a DataGridView does not have a SetDataBinding method or property or whatever.
However a DataGridView has a DataSource property.

In later versions, no method called SetDataBinding

else
            {

                this.dataGridView.DataSource = ds;
                this.dataGridView.DataBind();
                          

            }

I don't know actually, it's called dataGridView or gridView or what but me and I refer to VS grid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.