Imports System.Data.SqlClient
Imports System.Data
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSearch.Click
Dim s As String
s = "SELECT * FROM TBLBARANG WHERE KodeBarang = B01 "
oTbl = getRecBySQL(s, "TBLBARANG").Tables(0)
grd.DataSource = oTbl
End Sub
Function getRecBySQL(ByVal sSQL As String, ByVal sTblName As String) As DataSet
Dim oconn As New SqlConnection()
oconn.ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=DATAKU;Integrated Security=True"
Dim ocmd As SqlCommand = New SqlCommand(sSQL, oconn)
ocmd.CommandType = CommandType.Text
Dim da As SqlDataAdapter = New SqlDataAdapter(ocmd)
Dim ds As New DataSet()
da.Fill(ds, sTblName)
getRecBySQL = ds
End Function
No comments:
Post a Comment