Data transfer accounting Tuesday, December 4, 2007

I recently upgraded my Internet connection to a data transfer one . The one in which you pay a monthly fee, and they give you a upper limit above which you should not go and if you go you pay dearly.

Obviously I wanted to account the amount of data transfer now for optimum usage. From my Linksys Wifi router to the Internet which routes Internet for 3 PC on my network. I desperately searched for a software that can account for the data transfer I do, also keep a track. Such that I can keep a upper-limit and do not end up paying extra. In my search I could not find one (If their is one out their then I need to re-learn my goggling skills) . Now I have decided to build one on my own. How will I do that ?

  1. Netmon and Winpcap can monitor data transfer check more here.
  2. I propose to filter / pipe all this data machine wise to a SQLite database. That would solve the purpose.
  3. Give whole application a VB.net front end.

Their may be a flaw in the above approach but I will take my chances and keep on posting under label netaccount

CoreLab PostgreSQL.net auth for login Friday, November 16, 2007

 

I wanted login access to one of my application through database table fields data on VB.NET  project. For this I devised the following

  1. A table that will have username and password
  2. A SQL query that would run and return record count and if count is = 1. This would be considered as success.

Here is the code that did the trick for me

Dim command As New CoreLab.PostgreSql.PgSqlCommand
Try
PgSqlConnection1.Open()
command = PgSqlConnection1.CreateCommand()
Dim uparam, pparam As New CoreLab.PostgreSql.PgSqlParameter
command.Parameters.Add("uparam", CoreLab.PostgreSql.PgSqlType.VarChar, 100).Value = TextBox1.Text.ToString 'this converts the VB.Net Text box to PostgreSQl data type
command.Parameters.Add("pparam", CoreLab.PostgreSql.PgSqlType.VarChar, 25).Value = TextBox2.Text.ToString
command.CommandText = "select * from authuser where uname = :uparam AND passwd = :pparam"
command.BeginExecuteNonQuery()
Dim rowcount As Integer
rowcount = command.GetRecordCount()
If rowcount = 0 Then
Label3.Text = "Retry Incorrect login or password "
PgSqlConnection1.Close()
Else
Me.Hide()
base.Show()
End If
PgSqlConnection1.Close()
Catch ex As Exception
MsgBox("An Error occured please contact administrator" & Chr(13) & ex.Message, MsgBoxStyle.Critical)
End Try
PgSqlConnection1.Close()





Added the above code in click event of a button in VB.NET form. Though it may not be a master piece code for many but for me it is.

My first road block on VB.net Tuesday, August 21, 2007

Fine the application I was developing was the typical one as you fire the app the login screen comes up. On response from the login page either it opened a MDI form or it may exit the program.

Problem: If I exit from the main login form which was in the main() section the program would exit clean and release all resources.

   1:  'on failed auth do following
   2:  Me.close ' close the login form   3:   




I could not find a way to show my MDI main form after a success authentication and hiding or killing the login form. So I did following 


   1:  'on sucess auth 
   2:  Me.hide() ' this would hide the login form 
   3:  mymdiform.show() 'show the form

the problem with this approach was that If I close the MDI form invoked by the login form it (login) still remains in the memory and does not release it. Even if the form is not visible on the screen it is still in memory hogging memory. Now the question was how to get rid of this problem


   1:  Me.Dispose() ' Dispose the MDI form
   2:  Application.Exit() ' Dispose the whole application


this did the trick the whole application would close, when the click event calls the above code it works. Not only this the classic window cross also works after this piece of code