- Messages
- 36
- Reaction score
- 0
- Points
- 26
Imports MySql.Data.MySqlClient
Public Class frmAddUpdateProduct
Dim adding As Boolean
Dim updating As Boolean
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
adding = True
updating = False
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost;username=root;password=root;database=database"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "insert into database.products (Product no,Product Code,Description,Barcode,Category,Unit Price,Stocks on Hand,ReOrder Level)values('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "','" & txtReOrderLevel.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
MessageBox.Show("Data Saved")
MysqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
End Sub
End Class
paki tignan na lang po sa screenshot ang error.
View attachment 339150
Public Class frmAddUpdateProduct
Dim adding As Boolean
Dim updating As Boolean
Dim MysqlConn As MySqlConnection
Dim COMMAND As MySqlCommand
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
adding = True
updating = False
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost;username=root;password=root;database=database"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "insert into database.products (Product no,Product Code,Description,Barcode,Category,Unit Price,Stocks on Hand,ReOrder Level)values('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "','" & txtReOrderLevel.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
MessageBox.Show("Data Saved")
MysqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
End Sub
End Class
paki tignan na lang po sa screenshot ang error.
View attachment 339150