Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone help me with this?

My question is that yesterday i inserted data in mysql. the data in mysql is compost of 22,000 records in 55 fields and when i check the data today it is lost? how does it happen? how can i fix it? does the problem is in network connection because im on a lan? i hope someone help me.

here is my code


VB
<pre lang="sql">Dim importantmessage As String
               importantmessage = MsgBox("ALL DATA COMPLETED, DO YOU WANT TO SAVE THIS?", vbYesNo)
               If importantmessage = vbYes Then
                   MaskedTextBox20.Text = DatePicker1.Text
                   Dim con As MySqlConnection = New MySqlConnection("server=192.168.1.1;Port=3306;Database=sginfo ;Uid=root;Pwd=sample;")
                   Dim cmdinsert As MySqlCommand = New MySqlCommand("INSERT INTO personinfo(surname,firstname,middlename,present_currentaddress,provincialaddress,noofchildren,height,weight,birthdate,age,birthplace,gender,civilstatus,educationalattain,schoolname,course,yearsofstudy,collegestatus,trainingschoolname,positiontrained,yearstrained,coursetrained,detachment,region,effdate,workstatus,empnumber,positionemployed,yearsofemployed,sssnumber,tinnumber,nbi,nbidate,pnp,pnpdate,priorexp,gdexp,guardposition,uniformdate,millitary,los,previousemp,licno,licdate,licexp,dateofemp,badgeno,neurocenter,neuroresult,neurodate,drugcenter,marijuana,shabu,drugresult,agency,histories,agepattern,depend,phil,pagibig) VALUES (@SurName,@FirstName,@MiddleName,@Present_CurrentAddress,@ProvincialAddress,@Noofchildren,@Height,@weight,str_to_date(birthdate,'%d-%m-%Y'),@age,@birthplace,@gender,@civilstatus,@educationalattain,@schoolname,@course,@yearsofstudy,@collegestatus,@trainingschoolname,@positiontrained,@yearstrained,@coursetrained,@detachment,@Region,str_to_date(@effdate,'%d-%m-%Y'),@workstatus,@empnumber,@positionemployed,@yearsofemployed,@sssnumber,@tinnumber,@nbi,@nbidate,@pnp,@pnpdate,@priorexp,@gdexp,@guardposition,@uniformdate,@millitary,@LOS,@previousemp,@licno,@licdate,@licexp,@dateofemp,@badgeno,@neurocenter,@neuroresult,@neurodate,@drugcenter,@marijuana,@shabu,@drugresult,@histories,@agency,@agepattern,@depend,@phil,@pagibig);")
                   cmdinsert.Parameters.AddWithValue("surname", txtsurname.Text)
                   cmdinsert.Parameters.AddWithValue("firstname", txtfirstname.Text)
                   cmdinsert.Parameters.AddWithValue("middlename", txtmiddlename.Text)
                   cmdinsert.Parameters.AddWithValue("present_currentaddress", txtaddress.Text)
                   cmdinsert.Parameters.AddWithValue("provincialaddress", txtprovince.Text)
                   cmdinsert.Parameters.AddWithValue("noofchildren", txtchildren.Text)
                   cmdinsert.Parameters.AddWithValue("height", txtheight.Text)
                   cmdinsert.Parameters.AddWithValue("weight", txtweight.Text)
                   cmdinsert.Parameters.AddWithValue("birthdate", DatePicker1.Text)
                   cmdinsert.Parameters.AddWithValue("age", txtage.Text)
                   cmdinsert.Parameters.AddWithValue("birthplace", txtbplace.Text)
                   cmdinsert.Parameters.AddWithValue("gender", cmbgender.Text)
                   cmdinsert.Parameters.AddWithValue("civilstatus", cmbcivil.Text)
                   cmdinsert.Parameters.AddWithValue("educationalattain", ComboBox4.Text)
                   cmdinsert.Parameters.AddWithValue("schoolname", TextBox11.Text)
                   cmdinsert.Parameters.AddWithValue("course", TextBox10.Text)
                   cmdinsert.Parameters.AddWithValue("yearsofstudy", TextBox9.Text)
                   cmdinsert.Parameters.AddWithValue("collegestatus", TextBox8.Text)
                   cmdinsert.Parameters.AddWithValue("trainingschoolname", TextBox6.Text)
                   cmdinsert.Parameters.AddWithValue("positiontrained", ComboBox3.Text)
                   cmdinsert.Parameters.AddWithValue("yearstrained", TextBox7.Text)
                   cmdinsert.Parameters.AddWithValue("coursetrained", TextBox1.Text)
                   cmdinsert.Parameters.AddWithValue("detachment", ComboBox2.Text)
                   cmdinsert.Parameters.AddWithValue("region", ComboBox7.Text)
                   cmdinsert.Parameters.AddWithValue("effdate", maskedtextbox3.Text)
                   cmdinsert.Parameters.AddWithValue("workstatus", ComboBox1.Text)
                   cmdinsert.Parameters.AddWithValue("empnumber", TextBox29.Text)
                   cmdinsert.Parameters.AddWithValue("positionemployed", TextBox30.Text)
                   cmdinsert.Parameters.AddWithValue("yearsofemployed", TextBox31.Text)
                   cmdinsert.Parameters.AddWithValue("sssnumber", TextBox5.Text)
                   cmdinsert.Parameters.AddWithValue("tinnumber", TextBox4.Text)
                   cmdinsert.Parameters.AddWithValue("nbi", TextBox3.Text)
                   cmdinsert.Parameters.AddWithValue("nbidate", textbox58.Text)
                   cmdinsert.Parameters.AddWithValue("pnp", TextBox2.Text)
                   cmdinsert.Parameters.AddWithValue("pnpdate", maskedtextbox5.Text)
                   cmdinsert.Parameters.AddWithValue("priorexp", TextBox24.Text)
                   cmdinsert.Parameters.AddWithValue("gdexp", TextBox25.Text)
                   cmdinsert.Parameters.AddWithValue("guardposition", ComboBox11.Text)
                   cmdinsert.Parameters.AddWithValue("uniformdate", maskedtextbox6.Text)
                   cmdinsert.Parameters.AddWithValue("millitary", TextBox26.Text)
                   cmdinsert.Parameters.AddWithValue("LOS", TextBox28.Text)
                   cmdinsert.Parameters.AddWithValue("previousemp", TextBox27.Text)
                   cmdinsert.Parameters.AddWithValue("licno", TextBox32.Text)
                   cmdinsert.Parameters.AddWithValue("licdate", maskedtextbox2.Text)
                   cmdinsert.Parameters.AddWithValue("licexp", maskedtextbox1.Text)
                   cmdinsert.Parameters.AddWithValue("dateofemp", maskedtextbox7.Text)
                   cmdinsert.Parameters.AddWithValue("badgeno", TextBox12.Text)
                   cmdinsert.Parameters.AddWithValue("neurocenter", TextBox14.Text)
                   cmdinsert.Parameters.AddWithValue("neuroresult", ComboBox6.Text)
                   cmdinsert.Parameters.AddWithValue("neurodate", maskedtextbox8.Text)
                   cmdinsert.Parameters.AddWithValue("drugcenter", TextBox15.Text)
                   cmdinsert.Parameters.AddWithValue("marijuana", ComboBox5.Text)
                   cmdinsert.Parameters.AddWithValue("shabu", ComboBox12.Text)
                   cmdinsert.Parameters.AddWithValue("drugresult", maskedtextbox9.Text)
                   cmdinsert.Parameters.AddWithValue("histories", RichTextBox1.Text)
                   cmdinsert.Parameters.AddWithValue("agency", combobox21.Text)
                   cmdinsert.Parameters.AddWithValue("agepattern", MaskedTextBox20.Text)
                   cmdinsert.Parameters.AddWithValue("depend", TextBox59.Text)
                   cmdinsert.Parameters.AddWithValue("phil", TextBox60.Text)
                   cmdinsert.Parameters.AddWithValue("pagibig", TextBox61.Text)

                   cmdinsert.CommandType = CommandType.Text
                   cmdinsert.Connection = con
                   con.Open()
                   cmdinsert.ExecuteNonQuery()
                   MsgBox("Information, Successfully saved")
Posted
Updated 11-Feb-14 21:32pm
v2
Comments
OriginalGriff 12-Feb-14 3:14am    
We can't tell - because we don't know how you inserted the records, or how you checked them.
Edit your question (using the "Improve question" widget) and add the code fragments to do the operations - just the relevant stuff, including a dozen or so lines each side for context or the whole method if it's not too big.
Crixalis Paul 12-Feb-14 4:02am    
sir i already improve it
OriginalGriff 12-Feb-14 4:02am    
OK - that saves one record - I can;t believe that you filled in 50+ fields, and pressed the ENTER button thrice 22,000 times yesterday - I know I wouldn't - so how did you enter the large number of records if it wasn't using that code?

And how did you check that the records had not been entered?
Crixalis Paul 12-Feb-14 4:25am    
Sir
Crixalis Paul 12-Feb-14 4:11am    
Sir that is my code i am using as of know.

let me give you an example to check that the data inserted exist, we decided to have a daily check for example:

Monday: Data has been saved
Tuesday: Inserted data exist
Wednesday: Inserted data exist
Thursday: Inserted data exist
Friday: Data is lost

How can i fix it?

1 solution

"let me give you an example to check that the data inserted exist, we decided to have a daily check for example:

Monday: Data has been saved
Tuesday: Inserted data exist
Wednesday: Inserted data exist
Thursday: Inserted data exist
Friday: Data is lost"


It's not that code then: either your code has a section which deletes records, or something external to you application has done it.

Check your code: find everywhere that can delete records and check that every single time you do it it has a WHERE clause - because if it doesn't, it will happily delete every record in the DB!
If it's something external, then your code won't show anything.

But...I'd start with the Logs: http://dev.mysql.com/doc/refman/5.0/en/server-logs.html[^] - have a good loog though and see if any commands are "wild" deletes, which shoudl help you locate the source.
It would have been easier to locate if you had used task-specific login IDs though: if all you apps are logging in as "root" then they all have total access to the DB and the log will only show that "root" deleted the records. If you can, set up separate users who are restricted to just the permissions they require to do their job - this means that logged info would at least tell you exactly which user (and hence which application) deleted the records.

Time to start digging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900