By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Command Execution

P: n/a
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
..NET 2.0, I assume?

Since you are not using one of the new DataSource objects, I would venture
that you need to open the connection before the Fill() and then close it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Niggy" wrote:
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

Nov 19 '05 #2

P: n/a
Thanks. I've done as you suggest, however, I still need to execute the
command text. How do I do this within the context of my existing code?

"Cowboy (Gregory A. Beamer) - MVP" wrote:
.NET 2.0, I assume?

Since you are not using one of the new DataSource objects, I would venture
that you need to open the connection before the Fill() and then close it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Niggy" wrote:
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

Nov 19 '05 #3

P: n/a
i guess you are missing a connection here or not using it..
check out this article
http://www.developerfusion.com/show/4278/1/
--
The best
srini
http://www.expertszone.com
"Niggy" wrote:
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

Nov 19 '05 #4

P: n/a
My code so far is:

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
' DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

But my datagrid remains the same. Any ideas?

"srini" wrote:
i guess you are missing a connection here or not using it..
check out this article
http://www.developerfusion.com/show/4278/1/
--
The best
srini
http://www.expertszone.com
"Niggy" wrote:
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

Nov 19 '05 #5

P: n/a
The correct code is:

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Cust_id As String
Cust_id = "select * from filename where Customer_id=" +
ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlConnection1.Open()
Me.MySqlCommand1.CommandText = Cust_id
Me.MySqlDataTable1.SelectCommand = Me.MySqlCommand1
Me.MySqlDataAdapter1.Fill(DataSet11)
Me.MySqlConnection1.Close()
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

"Niggy" wrote:
I think I'm missing an execute command here. Please help.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.Label1.Text = ListBox1.SelectedItem.Value()
Me.DataGrid1.Visible = False
Me.MySqlCommand2.CommandText = "select * from filename where
Customer_id=" + ListBox1.SelectedItem.Value
Me.MySqlDataTable2.SelectCommand = Me.MySqlCommand2
Me.DataSet11.Reset()
Me.MySqlDataAdapter2.Fill(DataSet11)
DataGrid1.DataSource = DataSet11
DataGrid1.DataBind()
Me.DataGrid1.Visible = True
End Sub

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.