สอบถามผู้รู้ครับ
พี่ๆครับผมขอรบกวนด้วยครับ ช่วยแปลงโค็ดสำหรับSQLให้เป็นAccessให้หน่อยครับ เป็นโค๊ดสำหรับนำข้อมูลในDatabaseมาสร้างเป็นกราฟ
Imports System.Data Imports System.Data.SqlClient Imports System.Windows.Forms.DataVisualization.Charting
Dim strConn As String = "Data Source=BKKSQL001\INSTANCE01;" & _ "Initial Catalog=Northwind;Integrated Security=True" Dim conn As New SqlConnection(strConn) Dim sqlProducts As String = "SELECT Top 8 ProductName, UnitsInStock FROM Products" Dim da As New SqlDataAdapter(sqlProducts, conn) Dim ds As New DataSet() da.Fill(ds, "Products") Dim ChartArea1 As ChartArea = New ChartArea() Dim Legend1 As Legend = New Legend() Dim Series1 As Series = New Series() Dim Chart1 = New Chart() Me.Controls.Add(Chart1) ChartArea1.Name = "ChartArea1" Chart1.ChartAreas.Add(ChartArea1) Legend1.Name = "Legend1" Chart1.Legends.Add(Legend1) Chart1.Location = New System.Drawing.Point(13, 13) Chart1.Name = "Chart1" Series1.ChartArea = "ChartArea1" Series1.Legend = "Legend1" Series1.Name = "Series1" Chart1.Series.Add(Series1) Chart1.Size = New System.Drawing.Size(800, 400) Chart1.TabIndex = 0 Chart1.Text = "Chart1" Chart1.Series("Series1").XValueMember = "ProductName" Chart1.Series("Series1").YValueMembers = "UnitsInStock" Chart1.DataSource = ds.Tables("Products")
|