| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1539 人关注过本帖
标题:[求助]未将对象引用设置到对象的实例。
只看楼主 加入收藏
khl
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-4-30
收藏
 问题点数:0 回复次数:1 
[求助]未将对象引用设置到对象的实例。

Imports System
Imports System.Data
Imports System.Drawing
Imports System.Data.OleDb

Module ConnToDB
Public ConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
Public ConnectStr As String = ConnStr & "Data Source=E:\寇换龙\data\student.mdb"
Public DataAdapter As OleDbDataAdapter
Public DataConnection As OleDbConnection
Public myDataSet As DataSet
Public Index As Integer
Public pepdom As Integer
Public No As String
Public Function GetDataFromDB(ByVal sqlstr As String) As DataSet
Try
Dim DataConnection As OleDbConnection
DataConnection.ConnectionString = ConnectStr
DataAdapter = New OleDbDataAdapter(sqlstr, DataConnection)
myDataSet = New DataSet
DataConnection.Open()
myDataSet.Clear()
DataAdapter.Fill(myDataSet)
DataConnection.Close()
If Not (myDataSet Is Nothing) Then
Return myDataSet
End If
Catch ex As Exception
Return Nothing
End Try
End Function

Public Function UpdateDataBase(ByVal sqlstr As String) As Boolean
Dim sqlconn As New OleDbConnection(ConnectStr)
Try
Dim cmdTable As OleDbCommand = New OleDbCommand(sqlstr, sqlconn)
cmdTable.CommandType = CommandType.Text
sqlconn.Open()
cmdTable.ExecuteNonQuery()
sqlconn.Close()
Catch ex As Exception
Return False
End Try
Return True
End Function
End Module
Public Class WebfrmLogin
Inherits System.Web.UI.Page
Public sqlstr As String
Public strID As String
Public pwd As String
Public DS As DataSet
Public table As String

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Image2 As System.Web.UI.WebControls.Image
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
strID = Trim(Me.TextBox1.Text)
If strID = "" Then
Me.Label4.Text = "请输入登录的用户名称。"
Exit Sub
End If
pwd = Trim(Me.TextBox2.Text)
sqlstr = "SELECT*FROM userID WHERE" & "(用户名='" & strID & "') "
DS = New DataSet
DS.Clear()
DS = GetDataFromDB(sqlstr)
If DS.Tables(0).Rows.Count > 0 Then
sqlstr = "SELECT*FROM userID WHERE" & "(用户名='" & strID & " ') AND (密码='" & pwd & " ') "
Dim myDS As DataSet
myDS = New DataSet
myDS.Clear()
myDS = GetDataFromDB(sqlstr)
If myDS.Tables(0).Rows.Count > 0 Then
pepdom = myDS.Tables(0).Rows(0)("权限")
Me.Response.Redirect("http://localhost/EIMS//WebfrmMain.aspx")
Else
Me.Label4.Text = "输入的密码不正确,请重新输入密码。"
Me.TextBox2.Text = ""
End If
Else
Me.Label4.Text = "查无此人,请确认是否有该用户存在。"
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
End If
End Sub
End Class



搜索更多相关主题的帖子: Public 实例 Microsoft 对象 Imports 
2006-05-05 10:24
十一月天
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:10
帖 子:3030
专家分:0
注 册:2006-4-19
收藏
得分:0 
你发错地方了,有论坛的,再有你也没说你的问题

当头晕的时候我终于明白了什么叫爱情。
2006-05-08 09:54
快速回复:[求助]未将对象引用设置到对象的实例。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.076948 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved