4 Replies - 672 Views - Last Post: 27 January 2013 - 04:46 PM Rate Topic: -----

#1 jeiceei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-November 12

Login using text files as a database problem

Posted 09 November 2012 - 01:01 PM

Hello, i just signed up.

Firstly i just want to indicate that i can't speak english very well but i got enough for this topic i think.

I have a personal project, not an assigment or a homework. I'm trying to learn the logic of VB.NET and my project is non-profit.

My project is simple video streaming system. I added it to HWID protection , but its not useful. Most of notebooks around have the same HWID. So i decided to make it with a login system with username/password. Today i tried to make it with MsSQL 2008 but i think i screwed up at all. And i decided to make it simple; with text files.

I searched and searched all day long.. Tried almost everything but it doesn't work i don't know why.

And i found a sample code part on this site, it's useful for me.Here it is.

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

      Dim Usernamereader As String = "G:\Text1.txt"
      Dim PasswordReader As String = "G:\Text2.txt"
      Dim TextLineUser As String
      Dim TextLinePass As String
      Dim CountUser As Integer
      Dim CountPass As Integer
      Dim CharUser As Char
      Dim CharPass As Char

      If System.IO.File.Exists(Usernamereader) And System.IO.File.Exists(PasswordReader) = True Then

          Dim objReaderUser As New System.IO.StreamReader(Usernamereader)
          Dim objReaderPass As New System.IO.StreamReader(PasswordReader)

          Do While objReaderUser.Peek() <> -1
              CountUser = 0
              For CountUser = 1 To 10
                  CountUser = CountUser + 1
                  TextLineUser = TextLineUser & CountUser - 1 & _
                      objReaderUser.ReadLine() & vbNewLine
              Next
              CharUser = GetChar(TextLineUser, 1)
          Loop

          Do While objReaderPass.Peek() <> -1
              CountPass = 0
              For CountPass = 1 To 10
                  CountPass = CountPass + 1
                  TextLinePass = TextLinePass & CountPass - 1 & _
                      objReaderPass.ReadLine() & vbNewLine
              Next
              CharPass = GetChar(TextLinePass, 1)
          Loop

          If txtUsername.Text = TextLineUser And txtPassword.Text = TextLinePass Then
              MsgBox("you logged in!")
              MsgBox(TextLineUser)
              MsgBox(TextLinePass)
              MsgBox(CountPass)
              MsgBox(CountUser)

          Else
              MsgBox("not good")
              MsgBox(TextLineUser)
              MsgBox(TextLinePass)
              MsgBox(CountPass)
              MsgBox(CountUser)

          End If

      Else

          MsgBox("file does not exist")

      End If  



I want to change this part
Dim Usernamereader As String = "G:\Text1.txt"
      Dim PasswordReader As String = "G:\Text2.txt"



, and i tried to make this part allow me to enter links to my text files on dropbox.

I used this at my hwid code part and i've tried to adapt it to login system but i couldn't...

Now im stuck and don't know what to do this is why i joined and started this topic.

I want users login to program with their usernames and passwords which are saved on this files.

Is This A Good Question/Topic? 0
  • +

Replies To: Login using text files as a database problem

#2 mikepet  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 4
  • Joined: 08-November 12

Re: Login using text files as a database problem

Posted 09 November 2012 - 01:58 PM

Look at the System.Net.HttpWebRequest and System.Net.HttpWebResponse classes. That should get you started.
Was This Post Helpful? 0
  • +
  • -

#3 jeiceei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-November 12

Re: Login using text files as a database problem

Posted 09 November 2012 - 02:41 PM

View Postmikepet, on 09 November 2012 - 01:58 PM, said:

Look at the System.Net.HttpWebRequest and System.Net.HttpWebResponse classes. That should get you started.

I did , but i couldn't handle it.. Could you be more spesific please ?
Was This Post Helpful? 0
  • +
  • -

#4 mikepet  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 4
  • Joined: 08-November 12

Re: Login using text files as a database problem

Posted 09 November 2012 - 04:28 PM

I haven't tested this code but essentially this is what you would need to do. Obviously, replace userUrl and passUrl with your proper URLs.

Dim userUrl As String
Dim passUrl As String

Dim userRequest As System.Net.HttpWebRequest
Dim passRequest As System.Net.HttpWebRequest
Dim response As System.Net.HttpWebResponse

userUrl = "http://www.domain.com/Text1.txt"
passUrl = "http://www.domain.com/Text2.txt"

userRequest = System.Net.HttpWebRequest.Create(userUrl)
response = userRequest.GetResponse()
Using reader As New IO.StreamReader(response.GetResponseStream())
    While Not reader.EndOfStream
       'Do something with your file contents using reader.ReadLine()
    End While
End Using
response.Close()

passRequest = System.Net.HttpWebRequest.Create(passUrl)
response = passRequest.GetResponse()
Using reader As New IO.StreamReader(response.GetResponseStream())
   While Not reader.EndOfStream
      'Do something with your file contents using reader.ReadLine()
   End While
End Using
response.Close()


Was This Post Helpful? 0
  • +
  • -

#5 jeiceei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 09-November 12

Re: Login using text files as a database problem

Posted 27 January 2013 - 04:46 PM

I did it with recording MAC adresses instead of HWID's :chinese:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1