I am working on a college project . The project is network Banking system. I have designed two programs, one for server(admin) and one for the client(customers). The connection is via TCP sockets. here is a brief description:
When the customer(client) logs in by providing the account number and password correctly, the networkstream object transmits account number properly but this is not the case with passwords.
When I extract the password on the server side it is not a valid string to fit into the Sql query for verifying the user details in the database. The password String looks like "abc with a missing closing double quotes. The buffer size is 10025.
Here is the server code:
Public Sub Client_Login()
networkStream = clientSocket.GetStream()
Dim bytes(10024) As Byte
networkStream.Read(bytes, 0, CInt(clientSocket.ReceiveBufferSize))
ClientID = (Encoding.ASCII.GetString(bytes))
networkStream.Flush()
networkStream.Read(bytes, 0, CInt(clientSocket.ReceiveBufferSize))
ClientPassword = (Encoding.ASCII.GetString(bytes))
networkStream.Flush()
connection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;data source= D:\Project(Pritam)\Networking Banking System\ActualDatabase.mdb")
SQL = "Select * from ClientInfo where Account_No= " & ClientID & " and [Password]='" & ClientPassword & "'"
command = New OleDbCommand(SQL, connection)
connection.Open()
reader = command.ExecuteReader()
reader.Read()
If reader.HasRows = True Then
Dim ClientAccountNumber As Integer = reader("Account_No")
Dim PasswordClient As String = reader("Password")
If ClientAccountNumber = Val(ClientID) And PasswordClient = (ClientPassword) Then
server_response = "Successful Login"
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(server_response)
networkStream.Write(sendBytes, 0, sendBytes.Length)
networkStream.Flush()
Here is the client code:
Private Sub cmdSignin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSignin.Click
If txtClientID.Text <> "" And txtClientPassword.Text <> "" Then
Try
networkStream = clientSocket.GetStream()
Dim to_server As Byte() = Encoding.ASCII.GetBytes(txtClientID.Text)
networkStream.Write(to_server, 0, to_server.Length)
to_server = Encoding.ASCII.GetBytes(txtClientPassword.Text)
networkStream.Write(to_server, 0, to_server.Length)
networkStream.Flush()
form_refresh()
Dim login_Thread As Threading.Thread = New Threading.Thread(AddressOf login_final)
login_Thread.Start()
Catch ex As Exception
MsgBox("Server not found" & vbCrLf & "Contact Administrator", MsgBoxStyle.Critical, "Notice!!")
Me.Close()
End Try
Else
Kindly help me as I've to submit my project very soon, please.
Thanking you in advance
--EDIT kschuler: tried to fix code blocks, bolded the actual question to make it stand out more.