| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 910 人关注过本帖
标题:ConnectionString 属性尚未初始化 急急急
只看楼主 加入收藏
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
 问题点数:0 回复次数:4 
ConnectionString 属性尚未初始化 急急急
Imports System.Data.OleDb
Public Class WebForm2
    Inherits System.Web.UI.Page

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

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

    End Sub
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents Label4 As System.Web.UI.WebControls.Label
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
    Protected WithEvents TextBox4 As System.Web.UI.WebControls.TextBox
    Protected WithEvents TextBox5 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    '注意: 以下占位符声明是 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 Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '在此处放置初始化页的用户代码
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objconn As OleDbConnection
        objconn = New OleDbConnection
        Dim objcmd As OleDbCommand
        Dim strsql, strdsn As String
        Dim userid1, pwd1, xm1, sex1, dep1 As String
        userid1 = TextBox1.Text
        pwd1 = TextBox2.Text
        xm1 = TextBox3.Text
        sex1 = TextBox4.Text
        dep1 = TextBox5.Text
        strdsn = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("library.mdb")
        objconn = New OleDbConnection(strdsn)
        If Not Check_BH(userid1) Then
            strsql = "insert into reader values('" & userid1 & "','" & pwd1 & "','" & xm1 & "','" & sex1 & "','" & dep1 & "')"
            objconn = New OleDbConnection(strdsn)
            objcmd = New OleDbCommand(strsql, objconn)
            objcmd.Connection.Open()
            objcmd.ExecuteNonQuery()
            objcmd.Connection.Close()
            Response.Write("<script language='javascript'> alert('注册成功');</script>")
        Else
            Response.Write("<script language='javascript'> alert('注册不成功请重新输入');</script>")
        End If
    End Sub

    Function Check_BH(ByVal bh As String) As Boolean
        Dim objconn As New OleDbConnection
        Dim strsql As String
        Dim objdr As OleDbDataReader
        Dim objcmd As OleDbCommand

        strsql = "select * from reader where userid=' " & bh & " '"
        objcmd = New OleDbCommand(strsql, objconn)
        objcmd.Connection.Open()
        objdr = objcmd.ExecuteReader()
        Check_BH = False
        While objdr.Read()
            Check_BH = True

        End While
    End Function
End Class
搜索更多相关主题的帖子: 属性 
2008-10-05 12:13
zsf2006
Rank: 1
来 自:博客园
等 级:新手上路
威 望:1
帖 子:315
专家分:0
注 册:2006-6-3
收藏
得分:0 
出什么问题,把出错的代码或文字贴出,重点出错的地方标记以下
如果你用的是vs2003,建议你装个vs2005,可以避免这些了

[[it] 本帖最后由 zsf2006 于 2008-10-5 13:03 编辑 [/it]]

光临我的博客:http://
2008-10-05 12:58
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
得分:0 
本人就是用2003的.不知道那里出错了,各位高手帮个忙谢谢
2008-10-05 14:28
zsf2006
Rank: 1
来 自:博客园
等 级:新手上路
威 望:1
帖 子:315
专家分:0
注 册:2006-6-3
收藏
得分:0 
提问题也要提的专业点吧,都不知道你哪里出错,还是那句,贴出错的。。。红色显示
别人也好看啊,才能更好的help U

光临我的博客:http://
2008-10-05 19:38
twtdd
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2008-6-12
收藏
得分:0 
objcmd.Connection.Open()也就是倒数第八句出错了,望大虾帮下忙
2008-10-06 22:49
快速回复:ConnectionString 属性尚未初始化 急急急
数据加载中...
 
   



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

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