Ciao ragazzi, vi spiego subito il mio problema: Devo costruire una pagina asp.net che mi vada ad inserire i dati di un utente in un database access, ma sono in difficoltà a causa di un errore che non riesco a risolvere:
il codice è:e l'errore restituito è:codice:<%@ Page Language="VB" %> <%@ register tagprefix="Banana" tagname="Header" src="header.ascx" %> <%@ register tagprefix="Banana" tagname="Menu" src="menu.ascx" %> <script runat="server"> sub Submit(obj as Object, e as EventArgs) if Page.IsValid then dim objUserDetails as New BananaMobile.UserDetails dim objUser as New BananaMobile.User objUserDetails.Username = tbUname.Text objUserDetails.Password = tbPword.Text objUserDetails.Firstname = tbFName.Text objUserDetails.Lastname = tbLName.Text objUserDetails.Address = tbAddress.Text objUserDetails.City = tbCity.Text objUserDetails.State = tbState.Text objUserDetails.ZIP = tbZIP.Text objUserDetails.Phone = tbPhone.Text objUserDetails.Email = tbEmail.Text objUser.AddUser(objUserDetail) Session("UserID") = objUserDetails.UserID FormsAuthetication.SetAuthCookie(objUserDetails.UserID, false) Response.Redirect("default.aspx") else lblMessage.Text = "Qualche informazione è errata. Utente non convalidato." end if end sub </script>non riesco a capire come risolvere questo problema, per completezza vi posto anche le parti dei miei files vb utilizzate qui:codice:Errore di compilazione Descrizione: Errore durante la compilazione di una risorsa necessaria per soddisfare la richiesta. Rivedere i dettagli relativi all'errore e modificare in modo appropriato il codice sorgente. Messaggio di errore del compilatore: BC30451: Name 'tbUname' is not declared. Errore nel codice sorgente: Riga 9: dim objUser as New BananaMobile.User Riga 10: Riga 11: objUserDetails.Username = tbUname.Text Riga 12: objUserDetails.Password = tbPword.Text Riga 13: objUserDetails.Firstname = tbFName.Text File sorgente: D:\ProgDiReti\register.aspx Riga: 11grazie x la pazienza e x eventuali aiuti...codice:Imports System Imports System.Data Imports System.Data.OleDb Namespace BananaMobile Public Class UserDetails public UserId as Integer public UserName as string public Password as string public FirstName as string public LastName as string public City as string public State as string public ZIP as string public Address as string public Phone as string public Email as string End Class Public Class User private objConn as new OleDbConnection("Provider=" & "Microsoft.Jet.OLEDB.4.0;" & "Data Source=D:\ProgDiReti\Banana.mdb") Public function Login(strUsername as String, strPassword as String) as Integer dim IntID as Integer Dim objCmd As New OleDbCommand("spLoginUser", objConn) objCmd.CommandType = CommandType.StoredProcedure Dim objParam As new OleDbParameter("@Username", OleDbType.Char) ObjParam.Value = strUsername objCmd.Parameters.Add(objParam) objParam = New OleDbParameter("@Password", OleDbType.Char) objParam.Value = strPassword objCmd.Parameters.Add(objParam) Try objConn.Open intID = cType(objCmd.ExecuteScalar, integer) objConn.Close Catch e as exception throw e end try if intID.ToString = "" then return 0 end if return intID end function public sub AddUser(objUser as UserDetails) dim intID as integer dim objReader as OleDbDataReader dim objCmdID as new OleDbCommand("SELECT MAX(UserID) FROM tblUsers", objConn) dim objCmd as new OleDbCommand("spAddUser", objConn) objCmd.CommandType = CommandType.StoredProcedure dim objParam as new OleDbParameter("@Username", OleDbType.Char) objParam.Value = objUser.Username objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Password", OleDbType.Char) objParam.Value = objUser.Password objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Firstname", OleDbType.Char) objParam.Value = objUser.Firstname objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Username", OleDbType.Char) objParam.Value = objUser.Username objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Lastname", OleDbType.Char) objParam.Value = objUser.Lastname objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Address", OleDbType.Char) objParam.Value = objUser.Address objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@City", OleDbType.Char) objParam.Value = objUser.City objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@State", OleDbType.Char) objParam.Value = objUser.State objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@ZIP", OleDbType.Char) objParam.Value = objUser.ZIP objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Phone", OleDbType.Char) objParam.Value = objUser.Phone objCmd.Parameters.Add(objParam) objParam = new OleDbParameter("@Email", OleDbType.Char) objParam.Value = objUser.Email objCmd.Parameters.Add(objParam) Try objConn.Open objCmd.ExecuteNonQuery objUser.UserID = CType(objCmdID.ExecuteScalar, Integer) objConn.Close Catch e as exception throw e end try if objUser.UserID.ToString = "" then objUser.UserID = 0 end if end sub End Class End Namespace

Rispondi quotando