15,899,314 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Xion1624 (Top 9 by date)
Xion1624
27-Mar-20 10:48am
View
not absolutely necessary cause i'm just trying to learn multiple inheritance
Xion1624
20-Mar-20 11:36am
View
Imports System.Security.Cryptography
Imports System.IO
Imports MySql.Data.MySqlClient
Module Con_Add
Public usrnameFriend As String
Public Conn As New MySqlConnection
Public ConTemp As New MySqlConnection
Public MsgSubject As String = String.Empty
Sub ConTempOpen()
ConTemp.ConnectionString = "server=" & My.Settings.Host & "; user id=" & My.Settings.User & "; password=" & My.Settings.Pass & "; database= " & My.Settings.dbName
Try
ConTemp.Open()
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & "Check your connection.", MsgBoxStyle.Critical, "Can not connect to the Database")
Application.Exit()
End Try
End Sub
Sub OpenConnection()
Conn.ConnectionString = "server=" & My.Settings.Host & "; user id=" & My.Settings.User & "; password=" & My.Settings.Pass & "; database= " & My.Settings.dbName
Try
Conn.Open()
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & "Check your connection." & vbNewLine & "Application will close.", MsgBoxStyle.Critical, "Can not connect to the Database")
Application.Exit()
End Try
End Sub
Function MD5Encrypter(ByVal strPass As String) As String
Dim Hasher As New MD5CryptoServiceProvider
Dim PasswordBytes As Byte() = New Byte(strPass.Length + 3) {}
Dim HashBytes As Byte()
For i As Integer = 0 To strPass.Length - 1
PasswordBytes(i) = CByte(Asc(strPass(i)))
Next
PasswordBytes(strPass.Length) = CByte(90)
PasswordBytes(strPass.Length + 1) = CByte(85)
PasswordBytes(strPass.Length + 2) = CByte(66)
PasswordBytes(strPass.Length + 3) = CByte(73)
HashBytes = Hasher.ComputeHash(PasswordBytes)
Dim NewHashBytes As Byte() = New Byte(HashBytes.Length + 3) {}
For j As Integer = 0 To hashBytes.Length - 1
newhashBytes(j) = hashBytes(j)
Next
newhashBytes(hashBytes.Length) = CByte(90)
newhashBytes(hashBytes.Length + 1) = CByte(85)
newhashBytes(hashBytes.Length + 2) = CByte(66)
newhashBytes(hashBytes.Length + 3) = CByte(73)
strPass = Convert.ToBase64String(newhashBytes)
Return strPass
End Function
Function ImageToBytes(ByVal imgPath As String) As String
Try
Dim Image_DP As Image = Image.FromFile(imgPath)
Dim Memories As MemoryStream = New MemoryStream()
Image_DP.Save(Memories, System.Drawing.Imaging.ImageFormat.Png)
Dim ImageBytes As Byte() = Memories.ToArray()
Dim StringImage As String = Convert.ToBase64String(ImageBytes)
Return StringImage
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & "Failed to convert image to bytes.", MsgBoxStyle.Critical, "Error Occurred")
End Try
End Function
End Module
(this is my connection module)
Xion1624
20-Mar-20 11:30am
View
it that code same for module too??
Xion1624
20-Mar-20 11:25am
View
sorry for multiple question mark
Xion1624
20-Mar-20 11:13am
View
already did that bro still same error
Xion1624
20-Mar-20 11:06am
View
Sub ConTempOpen()
ConTemp.ConnectionString = "server=" & My.Settings.Host & "; user id=" & My.Settings.User & "; password=" & My.Settings.Pass & "; database= " & My.Settings.dbName
Try
ConTemp.Open()
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & "Check your connection.", MsgBoxStyle.Critical, "Can not connect to the Database")
Application.Exit()
End Try
End Sub
Sub OpenConnection()
Conn.ConnectionString = "server=" & My.Settings.Host & "; user id=" & My.Settings.User & "; password=" & My.Settings.Pass & "; database= " & My.Settings.dbName
Try
Conn.Open()
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & "Check your connection." & vbNewLine & "Application will close.", MsgBoxStyle.Critical, "Can not connect to the Database")
Application.Exit()
End Try
End Sub
(where do i add that???)
Xion1624
20-Mar-20 10:19am
View
should i put connection property inside using block or is there a way to put property in connection class and connect it with new connection inside using block ??????
Xion1624
20-Mar-20 8:31am
View
Thanks a lot sir.
Xion1624
16-Mar-20 12:08pm
View
The best approach is not to "recycle" SQL connections: create it in a Using block, open it, use it, and let the system Dispose it when it goes out of scope.
can you please describe above sentence a bit more clearly?
But why are you looping at all? Your loop just overwrites all previous messages with the last one it reads from the DB ... and given this is a chat app you are retrieving all the messages in the system each time which is a very, very inefficient way to do anything.
and also can you please tell me how do i do this since i've just started learning vb and i'm doing this for my school project
Show More