Example Code ASP.NET
Imports System.Data.OleDb
Public Class Class1
Public Shared con As New OleDbConnection(ConfigurationSettings.AppSettings("CONN2"))
Public Shared com As New OleDbCommand
Public Shared newval, tgToSQL As String
Public Shared appStrConn, appUserName, appPassword As String
Public Shared dbConnection As OleDbConnection
Public Shared dbCommand As OleDbCommand
Public Shared dr As OleDbDataReader
Public Shared status As Integer
Public Shared temp As String
Public Shared strConn As String
Public Shared pnlDefaultMenu As Panel
Public Shared bbndata As String
Public Shared Sub cekKoneksi()
If con.State = Data.ConnectionState.Open Then
con.Close()
End If
End Sub
End Class
Imports System.Data.OleDB
Imports Class1
Sub tampilgridview1()
Dim tabel As New DataTable
com.CommandText = "SELECT nofaktur, nama, alamat, kddealer, namadealer FROM lookup_register WHERE (tgregbpkb IS NULL) ORDER BY nofaktur"
cekKoneksi2()
con.Open()
com.Connection = con
dr = com.ExecuteReader
If dr.HasRows = True Then
tabel.Load(dr)
GridView1.DataSource = tabel
GridView1.DataBind()
End If
con.Close()
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
displaydata()
End Sub
Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView2.PageIndexChanging
Response.Write("
NewpageIndex: " & e.NewPageIndex)
GridView2.PageIndex = e.NewPageIndex
tampilgridview2()
End Sub
Public Sub ClearTextBox(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBox(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
Next ctrl
End Sub
Protected Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
ClearTextBox(Me)
End Sub
Protected Sub Button11_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button11.Click
Dim tabel As New DataTable
Dim tes As String
tes = "SELECT .. WHERE " & DropDownList2.SelectedItem.Value & " LIKE '%" & txtcaridatabpkb.Text & "%'"
com.CommandText = tes
cekKoneksi2()
con.Open()
com.Connection = con
dr = com.ExecuteReader
If dr.HasRows = True Then
tabel.Load(dr)
GridView2.DataSource = tabel
GridView2.DataBind()
End If
con.Close()
End Sub
---------------------
Dim tes As String
cekKoneksi2()
con.Open()
tes = "INSERT INTO BPKB_MASTER(NOREG_A,NOREG_B,NOREG_C," & _
"NOREG_D,NM_DITLANTAS,TGREGISTER,NOBPKBA,NOBPKB,NOBPKBC," & _
VALUES ('" & edRegA.Text & "','" & edRegB.Text & "'" & _
",'" & edRegC.Text & "','" & edRegD.Text &
com.CommandText = tes
com.Connection = con
com.ExecuteNonQuery()
con.Close()
-------
If Trim(TextBox2.Text) = "" Or Trim(ComboBox1.SelectedValue) = "" Then
MsgBox("Inputan tidak boleh kosong")
Else
cekKoneksi()
con.Open()
com.CommandText = "update Kamar set ID_Paket_Kelas = '" & ComboBox1.SelectedValue & "', Lokasi = '" & TextBox2.Text & "', Status = '" & ComboBox2.SelectedValue & "' where No_Kamar = '" & TextBox1.Text & "'"
com.Connection = con
com.ExecuteNonQuery()
con.Close()
hapus()
MsgBox("Data telah diubah")
--------
Tidak ada komentar:
Posting Komentar