abdul_samad
Member
- Joined
- Nov 5, 2007
- Messages
- 6
- Programming Experience
- 1-3
HI ADMIN
I AM USING MS ACCESS FIELDS AMOUNT DISCOUNT ,DISCOUNTAMOUNT , NETAMOUNT . UPDATE PROBLEM IN DATABASE CODE THIS FIELDS IN CAPITAL LATERS NO SPACE.
CODE HERE. Error coming is "could not update;currently locked
__________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Try
If ComboBox2.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or ComboBox3.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = "" Or TextBox7.Text = "" Then
MessageBox.Show("SOME FIELDS ARE EMPTY", "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Else
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb")
cn.Open()
cmd = New OleDbCommand("select * from stock", cn)
dr = cmd.ExecuteReader
While dr.Read
If Val(TextBox8.Text) = dr(8) Then
qtybal = qtybal + Val(TextBox13.Text)
amountbal = qtybal * Val(TextBox12.Text)
netamountbal = amountbal - Val(TextBox7.Text)
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set QTY=" & qtybal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set AMOUNT=" & amountbal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set NETAMOUNT=" & netamountbal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show("STOCK IS UPDATED # " & icount & " RECORD", "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
ComboBox2.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ComboBox3.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox15.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox20.Text = ""
TextBox7.Text = ""
ComboBox2.Focus()
End If
End While
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb")
cn.Open()
str = "insert into stock values('" & DateTimePicker1.Value & "','" & ComboBox2.Items.Item(ComboBox2.SelectedIndex) & "','" & TextBox2.Text & "'," & CInt(TextBox3.Text) & ",'" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & ComboBox3.Items.Item(ComboBox3.SelectedIndex) & "'," & CInt(TextBox8.Text) & ",'" & TextBox9.Text & "','" & TextBox10.Text & "'," & CInt(TextBox11.Text) & "," & CInt(TextBox12.Text) & "," & CInt(TextBox13.Text) & "," & CInt(TextBox14.Text) & "," & CInt(TextBox15.Text) & "," & CInt(TextBox16.Text) & "," & CInt(TextBox17.Text) & ")"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery()
MessageBox.Show("NEW ITEM ADDED IN STOCK RECORD NO #" & icount, "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
ComboBox2.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ComboBox3.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox15.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox20.Text = ""
TextBox7.Text = ""
ComboBox2.Focus()
Catch ex As Exception
End Try
End If
'Catch ex As Exception
'End Try
Try
cmd = New OleDbCommand("select * from purchaseorder", cn)
dr = cmd.ExecuteReader
While dr.Read()
icount = dr(1)
End While
icount = icount + 1
TextBox19.Text = (icount)
Catch ex As Exception
End Try
' Button2.Enabled = False
Button1.Enabled = True
cn.Close()
dr.Close()
_____________________________________________________________
qtybal varibale use in textbox lostfocus
netamoutbal also
netamountbal also
thankx sir
I AM USING MS ACCESS FIELDS AMOUNT DISCOUNT ,DISCOUNTAMOUNT , NETAMOUNT . UPDATE PROBLEM IN DATABASE CODE THIS FIELDS IN CAPITAL LATERS NO SPACE.
CODE HERE. Error coming is "could not update;currently locked
__________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Try
If ComboBox2.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or ComboBox3.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = "" Or TextBox7.Text = "" Then
MessageBox.Show("SOME FIELDS ARE EMPTY", "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Else
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb")
cn.Open()
cmd = New OleDbCommand("select * from stock", cn)
dr = cmd.ExecuteReader
While dr.Read
If Val(TextBox8.Text) = dr(8) Then
qtybal = qtybal + Val(TextBox13.Text)
amountbal = qtybal * Val(TextBox12.Text)
netamountbal = amountbal - Val(TextBox7.Text)
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set QTY=" & qtybal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set AMOUNT=" & amountbal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb;")
cn.Open()
str = "Update stock set NETAMOUNT=" & netamountbal & " where ITEMCODE=" & CInt(TextBox8.Text)
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show("STOCK IS UPDATED # " & icount & " RECORD", "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
ComboBox2.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ComboBox3.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox15.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox20.Text = ""
TextBox7.Text = ""
ComboBox2.Focus()
End If
End While
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory\WindowsApplication1\inventory.mdb")
cn.Open()
str = "insert into stock values('" & DateTimePicker1.Value & "','" & ComboBox2.Items.Item(ComboBox2.SelectedIndex) & "','" & TextBox2.Text & "'," & CInt(TextBox3.Text) & ",'" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & ComboBox3.Items.Item(ComboBox3.SelectedIndex) & "'," & CInt(TextBox8.Text) & ",'" & TextBox9.Text & "','" & TextBox10.Text & "'," & CInt(TextBox11.Text) & "," & CInt(TextBox12.Text) & "," & CInt(TextBox13.Text) & "," & CInt(TextBox14.Text) & "," & CInt(TextBox15.Text) & "," & CInt(TextBox16.Text) & "," & CInt(TextBox17.Text) & ")"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery()
MessageBox.Show("NEW ITEM ADDED IN STOCK RECORD NO #" & icount, "COFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
ComboBox2.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ComboBox3.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox15.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox20.Text = ""
TextBox7.Text = ""
ComboBox2.Focus()
Catch ex As Exception
End Try
End If
'Catch ex As Exception
'End Try
Try
cmd = New OleDbCommand("select * from purchaseorder", cn)
dr = cmd.ExecuteReader
While dr.Read()
icount = dr(1)
End While
icount = icount + 1
TextBox19.Text = (icount)
Catch ex As Exception
End Try
' Button2.Enabled = False
Button1.Enabled = True
cn.Close()
dr.Close()
_____________________________________________________________
qtybal varibale use in textbox lostfocus
netamoutbal also
netamountbal also
thankx sir