Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
objConn = New OleDbConnection(strConnString)
If objConn.State = ConnectionState.Close Then
objConn.Open()
End If
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\recruitment.mdb"
Dim conn As New OleDbConnection(connString)
'' 2 sql text // cm
Dim sqltext As String = "SELECT No_Q,Question FROM [QATest]"
Dim cmd As New OleDbCommand(sqltext, conn)
Dim da As New OleDbDataAdapter
Dim sr As DataTable
'' 3 execute + read
Try
Using conn
'' open
conn.Open()
sr = cmd.ExecuteReader()
'If sr.Read = False Then
While (sr.Read)
'Response.Write("21")
''MsgBox(sr.GetString(0) & ", " & sr.GetInt32(1))
Dim no_id As Integer
no_id = sr.GetInt32(0)
'Response.Write("22")
no_id += 1
IDLabel.Text = CStr(no_id)
End While
' IDLabel.Text = "1"
' id = CInt(IDLabel.Text)
' End If
'' num = Conver.toInt32(cmd.ExxcuteScalar())
End Using
Catch ex As Exception
IDLabel.Text = "1"
''Response.Write("เกิด error ขึ้น")
End Try
End Sub
End Class
Date :
2009-05-13 15:06:14
By :
mazaki
No. 4
Guest
ช่วยเขียนโค๊ด vb.net v.2008 หน่อยนะค่ะ
คืออยากจะได้โค๊ด random ข้อสอบช้อยอ่ะค่ะ
อยากให้ random จากฐานข้อมูล MySql
โดยเอานำมาโชว์ แค่หน้าละ 1 ข้อ แล้วก็ next ไปเรื่อยๆอย่างงี้อ่าค่ะ