'
' Created by SharpDevelop.
'
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports System.Data
Imports System.Data.SqlClient
Public Partial Class MainForm
Public Sub New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Sub Button1Click(sender As Object, e As EventArgs)
Dim dt1 As New DataTable
Dim SqlConn As New SqlConnection
Dim SqlCmd As New SqlCommand
Dim SqlWrt As New SqlDataAdapter
Dim Cmd As String
SqlConn.ConnectionString=" server=*IPหรือชื่อ ของ Server*;database=Northwind;user id=sa"
SqlConn.Open
Cmd="select * from Categories"
SqlCmd.CommandText=Cmd
SqlCmd.Connection=SqlConn
sqlWrt.SelectCommand=SqlCmd
sqlWrt.Fill(dt1)
If dt1.Rows.Count>0 Then
TextBox1.Text=dt1.Rows(0)("CategoryName")
dataGridView1.DataSource=dt1
End If
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt1 As New DataTable
Dim SqlConn As New SqlConnection
Dim SqlCmd As New SqlCommand
Dim SqlWrt As New SqlDataAdapter
Dim Cmd As String
SqlConn.ConnectionString = "server=*erpserver*;database=nyrubber;user id=sa;password=tum"
SqlConn.Open()
Cmd = "select *from PNrubber"
SqlCmd.CommandText = Cmd
SqlCmd.Connection = SqlConn
SqlWrt.SelectCommand = SqlCmd
SqlWrt.Fill(dt1)
If dt1.Rows.Count > 0 Then
TextBox1.Text = dt1.Rows(0)("PNtruckno")
DataGridView1.DataSource = dt1
End If
End Sub