List Info

Thread: C-Sharp (C#) Group: MySQL to a Datagrid




C-Sharp (C#) Group: MySQL to a Datagrid
user name
2006-11-14 21:18:40
The code:

------
string connectionString =
                      "Server=" + db_server +
";" +
                      "Database=" + db_database +
";" +
                      "User ID=" + db_uname +
";" +
                      "Password=" + db_passwd +
";" +
                      "Pooling=false;";
            MySqlConnection db_connection = new
MySqlConnection(connectionString);

            string query = "SELECT * FROM " +
db_table + ";";

            MySqlDataAdapter db_adapter = new
MySqlDataAdapter(query,
db_connection);
            DataSet db_data = new DataSet();
            try
            {
                db_adapter.Fill(db_data);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message.ToString());
            }
            dbgView.DataSource = db_data.DefaultViewManager;
            db_connection.Close();

------

Everything flows swell and executes.  But my datagrid
(dbgView) still
comesup empty.

Any help?

SigmaX


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups-beta.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: MySQL to a Datagrid
user name
2006-11-16 21:53:05
I think you just need to call dbgView.DataBind();

On Nov 14, 4:18 pm, "SigmaX"
<fyedernoggersnod...gmail.com> wrote:
> The code:
>
> ------
> string connectionString =
>                       "Server=" + db_server +
";" +
>                       "Database=" +
db_database + ";" +
>                       "User ID=" + db_uname +
";" +
>                       "Password=" + db_passwd
+ ";" +
>                       "Pooling=false;";
>             MySqlConnection db_connection = new
> MySqlConnection(connectionString);
>
>             string query = "SELECT * FROM " +
db_table + ";";
>
>             MySqlDataAdapter db_adapter = new
MySqlDataAdapter(query,
> db_connection);
>             DataSet db_data = new DataSet();
>             try
>             {
>                 db_adapter.Fill(db_data);
>             }
>             catch (Exception err)
>             {
>                
MessageBox.Show(err.Message.ToString());
>             }
>             dbgView.DataSource =
db_data.DefaultViewManager;
>             db_connection.Close();
>
> ------
>
> Everything flows swell and executes.  But my datagrid
(dbgView) still
> comesup empty.
> 
> Any help?
> 
> SigmaX


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups-beta.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: MySQL to a Datagrid
user name
2006-11-20 04:12:11
If you are doing an ASP page, you will need the DataBind
method.  In
either case try setting your DataSource as the following

dbgView.DataSource = db_data.Tables[0];

You CAN bind a datasource to a datatable (I do it all the
time) but it
needs to be to a datatable and not a dataset.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups-beta.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )