Can someone good with Classes please help on this

Results 1 to 3 of 3

Thread: Can someone good with Classes please help on this

  1. #1
    Join Date
    Dec 1969

    Default Can someone good with Classes please help on this

    Hi I have a business object that contains 2 classes. UserDetails and User. Its just wraps away my db login functionality. The problem I am getting is that the vbc is throwing up lots of errors when i go to compile it. <BR><BR>How can I debug a class in a gui enviroment. Its annoying as with an page if you run it and it has errors it gives your a pointer to where you are going wrong. But I just cannot seem to be able to debug a class. <BR><BR>Once i am in my bin dir this is how I am compiling it. <BR><BR>vbc /t:library /out:CustomClass /r:System.dll /r:System.Data.dll UserASP.vb<BR><BR>Heres my code <BR><BR>&#039; UserASP.vb<BR>&#039;<BR><BR>Import System<BR>Import System.Data<BR>Import System.Data.OleDb <BR><BR><BR>Namespace CustomClass<BR><BR><BR>Public Class UserDetails <BR><BR>public UserID as Integer <BR>public Username as String <BR>public Password as String <BR>public FirstName as String <BR>public LastName as String <BR>public City as String <BR>public County as String <BR>public Postcode as String <BR>public Address as String <BR>public Phone as String <BR>public Email as String <BR><BR>End Class <BR><BR><BR>Public Class User<BR><BR>private objConn as New OleDbConnection("Provdider= Microsoft.JET.OLEDB.4.0;" & _<BR>"Data Source=c:dataDatabase.mdb")<BR><BR><BR>public Function Login(strUsername as string, strPassword as string)<BR>dim intID as Integer<BR><BR>dim objComm as New OleDbCommand("spLoginUser", objConn)<BR>objComm.CommandType = objComm.CommandType.StoredProcedure <BR><BR>dim objParam as New OleDbParameter("@Username", OleDbType.Char)<BR>objParam.Value = strUsername <BR>objComm.Parameters.Add(objParam)<BR><BR>objPar am = New OleDbParameter("@Password", objConn)<BR>objParam.Value = strPassword<BR>objComm.Parameters.Add(objParam)<BR ><BR>try <BR>objConn.Open <BR>intID = CType(objComm.ExecuteScalar, Integer)<BR>objConn.Close <BR>Catch e As Exception <BR>throw e <BR>End try<BR><BR>if intID.ToString = 0 Then <BR>Return 0<BR>Else <BR>Return intID<BR>End If <BR>End Function<BR><BR>End Class <BR>End Namespace <BR><BR><BR>Please someone help.<BR>

  2. #2
    Join Date
    Dec 1969

    Default Assembly?

    Have you tried assemblies?<BR>Put a directive on an aspx page like...<BR><BR>&#060;%@ Assembly Src="UserASP.vb" %&#062;<BR><BR>... where UserASP.vb is whatever you called the source code file. You can instantiate objects and get very precise debug output without having to compile the component. When you are satisfied with the product, then you compile it and roll it out, and change over to an Import directive.

  3. #3
    Join Date
    Dec 1969

    Default I see a couple of errors...

    Functions *MUST* be given a return type:<BR><BR>public Function Login(strUsername as string, strPassword as string) [hl="yellow"] AS INTEGER[/hl]<BR><BR>*********<BR><BR>Why would you convert an integer to a string and then...turn around and compare it to an integer!!!????<BR><BR>if intID[hl="pink"].ToString[/hl] = 0 Then <BR><BR>Dump the .ToString, of course.<BR><BR>********<BR><BR>But then WHY would you EVER code this???<BR><BR> if intID = 0 Then <BR> Return 0<BR> Else <BR> Return intID<BR> End If <BR><BR>Ummm...can you please tell me what the heck is the difference between doing that and simply doing<BR> Return intID<BR>?????<BR><BR>************<BR><BR>And you don&#039;t see anything inconsistent here?<BR><BR>dim objParam as New OleDbParameter("@Username", OleDbType.Char)<BR>objParam = New OleDbParameter("@Password", objConn)<BR><BR>????<BR><BR>**************<BR><BR>What is the point of your UserDetails class???<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts