embehoclaptrinh
New member
- Joined
- Sep 22, 2006
- Messages
- 1
- Programming Experience
- Beginner
I doing a project have use a AxMSChart.
I don't know how I can binding a dataset to AxMSChart.
My code:
Private Sub btnBinding_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBinding.Click
Dim sConn As New String("Server=MINHQUAN;Database=pubs;UID=sa; PWD=sa;")
Dim sSQL As New String(" select idphong, count(case gioitinh when 0 then gioitinh end) as nu, count(case gioitinh when 1 then gioitinh end) as nam, count(gioitinh) as tong from nhanvien group by idphong ")
Dim oConn As New SqlConnection(sConn)
oConn.Open()
Dim oCmd As New SqlCommand(sSQL, oConn)
Dim oAdapter As New SqlDataAdapter(oCmd)
Dim oDataset As New DataSet
oDataset.Clear()
oAdapter.Fill(oDataset, "tblABC")
AxMSChart1.DataSource = oDataset.Tables("tblABC")
AxMSChart1.Show()
End Sub
Error Report:
An unhandled exception of type 'System.InvalidCastException' occurred in CSDL SQL.exe
Additional information: Specified cast is not valid.
Help me!
I don't know how I can binding a dataset to AxMSChart.
My code:
Private Sub btnBinding_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBinding.Click
Dim sConn As New String("Server=MINHQUAN;Database=pubs;UID=sa; PWD=sa;")
Dim sSQL As New String(" select idphong, count(case gioitinh when 0 then gioitinh end) as nu, count(case gioitinh when 1 then gioitinh end) as nam, count(gioitinh) as tong from nhanvien group by idphong ")
Dim oConn As New SqlConnection(sConn)
oConn.Open()
Dim oCmd As New SqlCommand(sSQL, oConn)
Dim oAdapter As New SqlDataAdapter(oCmd)
Dim oDataset As New DataSet
oDataset.Clear()
oAdapter.Fill(oDataset, "tblABC")
AxMSChart1.DataSource = oDataset.Tables("tblABC")
AxMSChart1.Show()
End Sub
Error Report:
An unhandled exception of type 'System.InvalidCastException' occurred in CSDL SQL.exe
Additional information: Specified cast is not valid.
Help me!