Recently i was coding an Point of sale system , in my system when the people that work at the store try to enter a new product in the database they should select if the product is a piece if it's a drink should be an L (liter), if it is vegetables like pears , apples (KG) kilograms . I created an string names tip(type) but i get an error , not every time i insert a product the type appears.
Here is my code:
konekcija = New MySqlConnection
konekcija.ConnectionString =
"server=localhost;userid=root;password=1234;database=baza;port=3307"
Dim READER As MySqlDataReader
Dim kupovnacena As Double
Dim prodaznacena As Double
Dim kolicina As Double
Dim profit As Double
Dim ddv As Double
Dim mkpr As String
Dim edmerka As String
If ComboBox3.SelectedIndex = 1 Then
edmerka = "парче"
End If
If ComboBox3.SelectedIndex = 2 Then
edmerka = "кг"
End If
If ComboBox3.SelectedIndex = 3 Then
edmerka = "мг"
End If
If ComboBox3.SelectedIndex = 4 Then
edmerka = "Л"
End If
COMMAND.Connection = konekcija
COMMAND.CommandText = "INSERT INTO baza.artikli VALUES(@kod,@naziv,@nabavna,@prodazna,@ddv,@kolicina,@opis,@opis2,@mkproizvod,@profit,@proizvoditel,@edmerka)"
COMMAND.Prepare()
COMMAND.Parameters.AddWithValue("@kod", TextBoxBarkod.Text)
COMMAND.Parameters.AddWithValue("@naziv", TextBoxNaziv.Text)
COMMAND.Parameters.AddWithValue("@nabavna", TextBoxKupovna.Text)
COMMAND.Parameters.AddWithValue("@prodazna", TextBoxProdazna.Text)
COMMAND.Parameters.AddWithValue("@ddv", ddv)
COMMAND.Parameters.AddWithValue("@kolicina", TextBoxKolicina)
COMMAND.Parameters.AddWithValue("@opis", TextBoxOpis.Text)
COMMAND.Parameters.AddWithValue("@opis2", TextBoxOpis2.Text)
COMMAND.Parameters.AddWithValue("@mkproizvod", mkpr)
COMMAND.Parameters.AddWithValue("@profit", profit)
COMMAND.Parameters.AddWithValue("@proizvoditel", TextBoxProizvoditel.Text)
COMMAND.Parameters.AddWithValue("@edmerka", edmerka)
COMMAND.ExecuteNonQuery()
COMMAND.ExecuteNonQuery(). You're doing an insert so you don't needREADER.