Start New Discussion within our Software Development Community

Hi, i am now want to insert data(fault and visual(bold)) into the table. After done the calculation, i would like to insert the fault and visual value into my table summary. My field name in table summary for fault(fo_ratio) and visual(visual) So below is my coding. How can i save into the database after done the calculation.Thanks.

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\LICHIN\Desktop\mys\YS.mdb"

con.Open()

sql = "SELECT * FROM summary WHERE line = '" & cbLine.Text & "' AND plants = '" & cbPlant.Text & "' AND dates = #" & dtp.Value & " #"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "summary")


maxrow = ds.Tables("summary").Rows.Count

If maxrow > 0 Then

MsgBox(cbLine.Text & " -" & dtp.Value & " -" & cbPlant.Text & " already exist")

Else

Try

Dim fault As Double
Dim ng As Integer
Dim input As Integer
Dim visual As Double

ng = Val(txtNg.Text)
input = Val(txtInput.Text)

fault = (ng / input) * 100
visual = 100 - fault


'first table summary

Dim addUser As String = "INSERT INTO summary (line, plants, dates,PartID, PartMD,total_count,ng,total_input) VALUES ( '" & cbLine.Text.ToUpper & "','" & cbPlant.Text.ToUpper & "', #" & dtp.Value & "#, '" & p1.Text & "', '" & p2.Text & "','" & txtCount.Text & "','" & txtNg.Text & "','" & txtInput.Text & "')"
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(addUser, con)
cmd.ExecuteNonQuery()




MsgBox("Data have been successfully save.")



Catch ex As Exception
MsgBox(ex.Message.ToString, , "Addition Error")

End Try

End If
con.Close()

insert the columns in the database
then use update statement to calculate fault and whatever you want

This article has been dead for over six months. Start a new discussion instead.