New Text Document

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View New Text Document as PDF for free.

More details

  • Words: 269
  • Pages: 2
Imports System.Data.OleDb Partial Class _Default Inherits System.Web.UI.Page Dim straccess As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\ihpnguyen\practice.mdb;Persist Security Info=True" Dim cnn As OleDbConnection Dim cmd As OleDbCommand Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' open connection Try cnn = New OleDbConnection(straccess) cnn.Open() Catch ex As Exception MsgBox(ex.ToString()) End Try ' process Dim sqlSelect As String = _ "select * from ware" cmd = New OleDbCommand(sqlSelect, cnn) Dim reader As OleDbDataReader reader = cmd.ExecuteReader() Dim str As String = "" str += "" str += "" str += "" str += "" Try While reader.Read str += "" str += "" str += "" End While Catch ex As Exception Finally Try reader.Close() Catch ex As Exception End Try End Try Dim indexnew As Integer = indexlast(cnn) savewarte(cnn,indexnew,'DELL') ' close connection Try cnn.Close() Catch ex As Exception

MsgBox(ex.ToString()) End Try str += "
STTHSXuatNSXuatTSPNGNHAP
" + reader.GetValue(0) str += "" + reader.GetValue(1) str += "" + reader.GetValue(2) str += "" + reader.GetValue(3) str += "" + reader.GetValue(4) str += "
" lbresult.Text = str End Sub Public Sub loadGrid(ByVal cmd As OleDbCommand) Dim da As New OleDbDataAdapter(cmd) Dim ds As New System.Data.DataSet() da.Fill(ds) gvlist.DataSource = ds gvlist.DataBind() End Sub Public Function indexlast(ByVal cnn As OleDbConnection) As Integer Dim sqlInsert = "SELECT ID FROM ware ORDER BY ID DESC" Dim cmd As New OleDbCommand(sqlInsert, cnn) Dim index As Integer = cmd.ExecuteScalar() Return index + 1 End Function Public Sub savewarte(ByVal cnn As OleDbConnection, ByVal index As Integer, ByVal company As String) Dim sqlInsert = "INSERT INTO ware VALUES(1,'Dell','USA','DELL D234','2009-02-15')" Dim cmd As New OleDbCommand(sqlInsert, cnn) cmd.ExecuteNonQuery() End Sub End Class

Related Documents

New Text Document
May 2020 1
New Text Document
June 2020 0
New Text Document
May 2020 1
New Text Document
October 2019 13
New Text Document
October 2019 9
New Text Document (4)
October 2019 11