Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Patulong mga lodi ...

adrian890

Novice
Advanced Member
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
 

Attachments

  • ERROR.jpg
    ERROR.jpg
    30.6 KB · Views: 30
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


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) values ('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader

MessageBox.Show("Data Saved")

txtProductno.Clear()
txtProductCode.Clear()
txtDescription.Clear()
txtBarcode.Clear()
txtCategory.Clear()
txtUnitPrice.Clear()
txtStocksonHand.Clear()


MysqlConn.Close()

Catch ex As MySqlException

MessageBox.Show(ex.Message)

Finally

MysqlConn.Dispose()

End Try

End Sub

saan ko ba ilalagay 'to bossing ??

Private Sub Button1_Click()

If txtProductno.Text = "" Then
MsgBox("Please fill empty fields")

Exit Sub
Else
' Code if not empty
End If
End Sub

End Class
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


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) values ('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader

MessageBox.Show("Data Saved")

txtProductno.Clear()
txtProductCode.Clear()
txtDescription.Clear()
txtBarcode.Clear()
txtCategory.Clear()
txtUnitPrice.Clear()
txtStocksonHand.Clear()


MysqlConn.Close()

Catch ex As MySqlException

MessageBox.Show(ex.Message)

Finally

MysqlConn.Dispose()

End Try

End Sub

saan ko ba ilalagay 'to bossing ??

Private Sub Button1_Click()

If txtProductno.Text = "" Then
MsgBox("Please fill empty fields")

Exit Sub
Else
' Code if not empty
End If
End Sub

End Class

lagay mo before yung Try clause...

If txtProductno.Text = "" Then
MsgBox("Please fill empty fields")
Exit Sub
End If
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


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) values ('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader

MessageBox.Show("Data Saved")

txtProductno.Clear()
txtProductCode.Clear()
txtDescription.Clear()
txtBarcode.Clear()
txtCategory.Clear()
txtUnitPrice.Clear()
txtStocksonHand.Clear()


MysqlConn.Close()

Catch ex As MySqlException

MessageBox.Show(ex.Message)

Finally

MysqlConn.Dispose()

End Try

End Sub

saan ko ba ilalagay 'to bossing ??

Private Sub Button1_Click()

If txtProductno.Text = "" Then
MsgBox("Please fill empty fields")

Exit Sub
Else
' Code if not empty
End If
End Sub

End Class

Im assuming na Web application ang ginagawa mo, sa HTML 5 may form validation na,

Code:
<input type="text" name="product_num" required>

or pd ka din gumawa ng function na Form validation,

Javascript:
Code:
function validateForm() {
    var x = document.forms["myForm"]["fname"].value;
    if (x == "") {
        alert("Name must be filled out");
        return false;
    }
}

then pwd mong eh call pag mag vavalidate ka ng input sa form sa IF ELSE statment,

Code:
If validateForm == true

Then
  Execute Query

Else
 Error measage
 
Last edited:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


MysqlConn = New MySqlConnection
MysqlConn.ConnectionString = "server=localhost;username=root;password=root;data base=database"
Dim READER As MySqlDataReader

Try
MysqlConn.Open()
Dim Query As String
Query = "insert into database.products (Product_no,Product_Code,Description,Barcode,Categ ory,Unit_Price,Stocks_on_Hand) values ('" & txtProductno.Text & "','" & txtProductCode.Text & "','" & txtDescription.Text & "','" & txtBarcode.Text & "','" & txtCategory.Text & "','" & txtUnitPrice.Text & "','" & txtStocksonHand.Text & "')"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader

MessageBox.Show("Data Saved")

txtProductno.Clear()
txtProductCode.Clear()
txtDescription.Clear()
txtBarcode.Clear()
txtCategory.Clear()
txtUnitPrice.Clear()
txtStocksonHand.Clear()


MysqlConn.Close()

Catch ex As MySqlException

MessageBox.Show(ex.Message)

Finally

MysqlConn.Dispose()

End Try

End Sub


paano po yung mag iinform sya na may empty textbox bago nya isave ??
wala po kasi akong mahanap sa google eh :(( ang hirap intindihin
 
lagay mo to before saving. magloop ito sa form mo at hahanapin nya lahat ng textbox sa form mo.. ang sort ng checking nito ay based sa tabindex ng mga control sa form mo.. pwede mo din ilagay sa Tag na property ng textbox kung anu yung lalabas na message sa kanya pag empty siya.

For Each i In Me.Controls.OfType(Of Control).OrderBy(Function(o) o.TabIndex)
If TypeOf i Is TextBox Then
With CType(i, TextBox)
If .Text = "" Then
MessageBox.Show("Message")
End If
End With
End If
Next
 
Back
Top Bottom