Source code will be coming soon
what need 2 textboxes
2 buttons
1 timer
demo project will be posted
in 12:00am tonight
Source code will be coming soon what need 2 textboxes 2 buttons 1 timer demo project will be posted in 12:00am tonight here is source code for vb.net mysql chat app Imports MySql.Data.MySqlClient Imports System Imports System.Security.Cryptography Imports System.Net Imports System.Text Imports System.Text.RegularExpressions Imports System.IO Imports System.Data.SqlClient Public Class Form1 Public Function mysqlconnection() As MySqlConnection 'return new connection. Return New MySqlConnection("server=servername; user id=username; password=serverpassword; database=databasename") End Function Public con As MySqlConnection = mysqlconnection() 'declaring the variables string Public sql As String Public result As String 'declaring the classes Dim cmd As New MySqlCommand Public dt As New DataTable Public da As New MySqlDataAdapter Private Sub Chat(ByVal sqlQuery As String) Try 'OPENING THE CONNECTION con.Open() 'HOLDS THE DATA TO BE EXECUTED With cmd .Connection = con .CommandText = sqlQuery End With 'EXECUTE THE DATA result = cmd.ExecuteNonQuery 'CHECKING IF THE DATA HAS BEEN EXECUTED OR NOT If result = 1 Then MsgBox("message has been sent") Else MsgBox("Failed to register the user.") End If con.Close() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click sql = "INSERT INTO `chat` (`chat_text`) VALUES ('" _ & TextBox2.Text & "' )" Chat(sql) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim conn As MySqlConnection conn = New MySqlConnection conn.ConnectionString = ("server=45.32.168.102; user id=newuser; password=password; database=user_register") Try conn.Open() Catch myerror As MySqlException MsgBox("No connection") End Try Dim myAdaptor As New MySqlDataAdapter Dim sqlquery = "SELECT * FROM `chat` ORDER BY `chat_text` ASC" Dim myCommand As New MySqlCommand() myCommand.Connection = conn myCommand.CommandText = sqlquery myAdaptor.SelectCommand = myCommand Dim myData As MySqlDataReader myData = myCommand.ExecuteReader() Dim sb As StringBuilder = New StringBuilder() While myData.Read() sb.AppendLine(myData("chat_text")) End While TextBox1.Text = sb.ToString myData.Close() conn.Close() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Button2.PerformClick() End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = True Timer1.Start() End Sub End Class thank you buddy, nice one, but why you don't make a tut about "How to use your codes?" * Thankful to Allah * Kurdy I though i can do TUT about this maybe. |
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
vb.net phishing application | viruss | 3 | 3,194 | 06-21-2017, 04:04 PM Last Post: Mr.Kurd |