你將onlogin的Sub寫到Login.vb吧直接Click圖片Button撰寫Event.

解决方案 »

  1.   

    你將onlogin的Sub寫到Login.vb吧直接Click圖片Button撰寫Event.
      

  2.   

    谢谢两位,按所讲方法后出错如下,如何解决?编译器错误信息: BC30001: 语句在命名空间中无效。源错误: 行 9:  imports System.Web.UI.HtmlControls
    行 10: 
    行 11:    sub onlogin(sender As Object, e As ImageClickEventArgs)
    行 12:         Dim thedb as new memberdb
    行 13:         session("code")=depart.SelectedItem.value
     源文件: E:\dbserver\login.vb    行: 11 
    显示完整的编译源:
    行 1:    
    行 2:    Imports System
    行 3:    Imports System.Data
    行 4:    Imports System.Data.Sqlclient
    行 5:    Imports System.Web
    行 6:    Imports System.web.UI
    行 7:    Imports System.Collections
    行 8:    imports System.Web.UI.WebControls
    行 9:    imports System.Web.UI.HtmlControls
    行 10:   
    行 11:      sub onlogin(sender As Object, e As ImageClickEventArgs)
    行 12:           Dim thedb as new memberdb
    行 13:           session("code")=depart.SelectedItem.value
    行 14:           session("pass")=password.text
    行 15:       
    行 16:           try
    行 17:               dim theid as string=thedb.isvaliduser(session("code").tostring(),session("pass").toString())
    行 18:               session("kind")=theid
    行 19:               Response.Redirect("default.aspx")
    行 20:           catch e1 as exception
    行 21:               ErrorMsg.Visible = true
    行 22:           end try
    行 23:       end sub
    行 24:    
    行 25:     
    行 26:       Public Class memberdb:inherits page
    行 27:           
    行 28:           
    行 29:           public kind as string
    行 30:           public code as string
    行 31:           public pass as string
    行 32:           
    行 33:           Public function isvaliduser(byval code as string,byval pass as string) as string
    行 34:               
    行 35:               dim appsetting as Hashtable=ctype(HttpContext.Current.GetConfig("appsettings"),Hashtable)
    行 36:               dim m_constring as string=CSTR(appsetting("guest"))
    行 37:               dim mycon as SQLConnection = new SQLConnection(m_constring)
    行 38:               dim mycommand as SQLCommand = new SQLCommand("dt_checkoutpass",mycon)
    行 39:               mycommand.commandtype=commandtype.storedprocedure
    行 40:               dim param as SQLParameter
    行 41:               
    行 42:               param = new SQLParameter("@code",SQLDbType.NVarChar,10)
    行 43:               param.value = code
    行 44:               mycommand.Parameters.Add(param)
    行 45:               
    行 46:               param = new SQLParameter("@pass",SQLDbType.NVarChar,10)
    行 47:               param.value = pass
    行 48:               mycommand.Parameters.Add(param)
    行 49:               
    行 50:               param = new SQLParameter("@kind",SQLDbType.NVarChar,10)
    行 51:               param.direction = parameterdirection.output
    行 52:               mycommand.Parameters.Add(param)
    行 53:               
    行 54:               try
    行 55:                   mycon.open()
    行 56:                   mycommand.executeNonQuery()
    行 57:               
    行 58:               catch e as exception
    行 59:                   throw e
    行 60:               
    行 61:               
    行 62:               
    行 63:               end try
    行 64:               
    行 65:               return cstr(param.value)
    行 66:               
    行 67:               end function
    行 68:       End Class