未将对象设置到实例化 超级紧急啊 拜托拜托~~请大神帮忙 在线等
Imports System.Data.OleDb
Imports System.IO
Public Class studentManage
Dim objDs As New DataSet
Dim objTSTable As DataTable
Dim objDa As New OleDbDataAdapter
Dim whereStr As String
Dim DBconnectionStr = "provider=microsoft.jet.oledb.4.0;" & "data source=" + Application.StartupPath + "\data\aa.mdb"
Public Sub bindgridview(ByVal strXH As String)
Dim objConn As New OleDbConnection
Dim objComm As New OleDbCommand
objConn.ConnectionString = DBconnectionStr
objComm.CommandText = "select * from studentManage"
If Trim(strXH) <> "" Then
objComm.CommandText = objComm.CommandText & strXH
End If
objComm.Connection = objConn
objDa.SelectCommand = objComm
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(objDa)
objConn.Open()
objDa.Fill(objDs, "studentManage")
objTSTable = objDs.Tables("studentManahe")
objConn.Close()
objDa.Fill(objTSTable)
DataGridView1.DataSource = objTSTable
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
whereStr = ""
If Trim(TextBox1.Text) <> "" Then
whereStr = "where 学号 like '%" + Trim(TextBox1.Text) + "%'"
End If
objTSTable.Clear()
bindgridview(whereStr)
Dim cn As OleDbConnection = New OleDbConnection(DBconnectionStr)
cn.Open()
Dim command As OleDbCommand = New OleDbCommand("select * from studentManage where学号 ='" + Trim(TextBox1.Text) + "'", cn)
Dim dr As OleDbDataReader = command.ExecuteReader
If (dr.Read()) Then
TextBox2.Text = dr("姓名").ToString()
If Trim(dr("性别")) = "女" Then
RadioButton2.Checked = True
End If
DateTimePicker1.Text = dr("出生日期").ToString()
End If
cn.Dispose()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "错误提示")
End Try
End Sub
End Class