|
Web design and Programming Discuss website creation and other programming topics. |
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||
|
Blades Chat Program
Ok so i wanted to make an app/program sort of like ICQ for those that remember it.
A simple chat program made in VB that works off my web hosting service. I finally found a tutorial sort of like what i wanted. The guy that did the video has moved on and didn't reply to emails, i found the source code which is slightly different to the video but mostly there with the missing bits, well most of them lol. I was hoping with help from some of you we might be able to get it working properly, never know might start a new community chat service. Software: I'm using VB 2017 Video Tutorial: The first 4 mins shows a working version https://www.youtube.com/watch?v=6mUCZq6pyvo If anyone is interested in the project i can send a link to all the files. So far.... I have the app complete but getting lots of little issues, it needs finishing and a little polish. I can register and login no worries When i Edit Profile which puts the details in, name, mobile, email, pass change. I get the error user already exists (see code example 1) Or i changed to another bit of code to do the same thing i get another issue of that users over rights all other users in the DB, so if i had 3 users Bob, Bill, Merry and edited Bob, there would be 3 entries of Bob and no Marry or Bill. (see code Example 2) Example 1 Code:
Imports MySql.Data.MySqlClient Public Class frmEditProfile Private Sub frmEditProfile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load con.Open() txtName.Text = My.Settings.FirstName txtEmail.Text = My.Settings.Email txtMobile.Text = My.Settings.Tel txtUsername.Text = My.Settings.Username End Sub Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click Dim cmdread As New MySqlCommand("SELECT * FROM users", con) Dim datareader As MySqlDataReader Try datareader = cmdread.ExecuteReader While datareader.Read() If datareader(1).ToString = txtUsername.Text And Not My.Settings.Username = txtUsername.Text Then MsgBox("Username already exists.", MsgBoxStyle.Exclamation, "Username Error") datareader.Close() Exit Sub End If If datareader(3).ToString = txtEmail.Text And Not My.Settings.Email = txtEmail.Text Then MsgBox("Email already exists.", MsgBoxStyle.Exclamation, "Email Error") datareader.Close() Exit Sub End If If datareader(6).ToString = txtMobile.Text And Not My.Settings.Tel = txtMobile.Text Then MsgBox("Mobile number already exists.", MsgBoxStyle.Exclamation, "Mobile No. Error") datareader.Close() Exit Sub End If End While datareader.Close() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Database Error") End Try End Sub Private Sub frmEditProfile_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing con.Close() End Sub End Class Code:
Public Class EditProfile #Region "declare" Dim mycmd As New MySqlCommand Dim myconnection As New DTConnection Dim objreader As MySqlDataReader #End Region Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click mycmd.Connection = myconnection.open mycmd.CommandText = "update users set username='" & txtUsername.Text & "',email='" & txtEmail.Text & "',password='" & txtPassword.Text & "', name='" & txtName.Text & "', mobile='" & txtMobile.Text & "' " mycmd.ExecuteNonQuery() myconnection.close() MsgBox("Data changed !!", MsgBoxStyle.Information, "Notice..") End Sub Private Sub EditProfile_Load(sender As Object, e As EventArgs) txtName.Text = My.Settings.FirstName txtEmail.Text = My.Settings.Email txtMobile.Text = My.Settings.Tel txtUsername.Text = My.Settings.Username End Sub Private Sub EditProfile_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class |
#2
|
||
|
Very interesting, I wish you luck with your project. That is way out of my lane in regards to experience but I am sure some others here would be a good fit.
__________________
"If the whole universe has no meaning, we should never have found out that it has no meaning: just as, if there were no light in the universe and therefore no creatures with eyes, we should never know it was dark. Dark would be without meaning." -- C.S. Lewis |
#3
|
||
|
Unfortunately I don't know much VB. Any reason you decided to go with VB instead of something like c#?
I think selecting the entire user database and looping through it is going to be a problem if you have many users. I also don't see if you're assigning a unique userid that isn't the username/email to the profile. You're query could look something like this: Code:
SELECT * FROM users WHERE username='new username' AND userid != 'current userid' For whatever reason, the comparison operators in VB don't compute in my head but I think the username compare line needs to be something like this: Code:
If datareader(1).ToString = txtUsername.Text And Not My.Settings.Username = datareader(1).ToString Then
__________________
04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq |
#4
|
|||
|
Quote:
Should i be looking to change it all over to C#? |
#5
|
||
|
Ok found another tutorial in C#
i will put it together and see how i go with this one and get back to you. :P |
#6
|
||
|
I would use something more widely supported and modern like c# but it's totally up to you.
__________________
04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq |
#7
|
||
|
C# is superior in every way. MS is phasing out VB.
__________________
Delta Force 2 Enhanced Modding Site, new and improved with forum. |
#8
|
||
|
Thanks for the feedback.....
I see most VB tuts are old and outdated but i thought it might be the way to go. I have started to redo it in C# The Registration and Login are done as is the DB info. I'm still learning so I'm expecting to hit walls and have issues. Next i will setup a chat page and see if i can send a message. |
#9
|
||
|
Well I'm starting to get somewhere with it, here is a short clip of what i have so far...
I managed to do the reg, login, change the font size color and background I'm trying to figure a few thing out but a few more hours of searching and i hope to sort them out It has a long ways to go but for someone without knowledge of coding or prier learning i think I'm doing ok I do have a question if anyone might know... I want to add a unique member id number starting a 1000000, so e.g. Scott is the user, membership id is 1000468. Users can search for id number to find user and add as a friend p.s. sorry for the crap recording, i just grabbed the first thing that records and made a quick clip, i will make a better one later as i progress Last edited by ~BLÃÐE~; 02-03-2021 at 03:54 AM. |
#10
|
||
|
Nice work blade!
If you're using a MySQL database you can start the auto_increment field at 100000000 (make sure it's an unsigned int field). When creating a new account, once you insert the user you can use LAST_INSERT_ID() on the table to find the last id you inserted so you can display it to the user.
__________________
04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq |
#11
|
||
|
Looking good!
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|