Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
hi every body,
i've got a problem on my save button: the same code with another table update (account) is working well, but the article's one is blocked, and i don't know why, every time i fill in the comboboxes and the textboxes then click on save button, it runs nomore, and when i'm back to the source code on my edi visual studio, i find the cursor blinking on the datadapt lines,
here is the code:
VB
Private Sub ButtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtnSave.Click
		sql = "select * from gm862"
		cmd = New MySqlCommand(sql)
		dataadapt = New MySqlDataAdapter(cmd)
		datset = New DataSet
		cmd.Connection() = cn
		dataadapt.Fill(datset, "gm862")	'dataadapter.Fill=remplir
		datatab = datset.Tables("gm862")
		If txtimei.Text = "" Or cmbxartifact.Text = "" Or cbxsurename.Text = "" Or cbxforename.Text = "" Or cmbxintiallatitude.Text = "" Or cmbxinitiallongitude.Text = "" Or txtcurrentlongitude.Text = "" Or txtcurrentlongitude.Text = "" Or datelab.Text = "" Or timelabuct.Text = "" Then
			MsgBox("Please fill in all fields !", MsgBoxStyle.Information, "Information")
		Else
			datrow = datset.Tables("gm862").NewRow
			datrow("refgm862") = txtimei.Text
			datrow("artefact") = cmbxartifact.Text
			datrow("usersurename") = cbxsurename.Text
			datrow("userforename") = cbxforename.Text
			datrow("initiallatitude") = CDbl(cmbxintiallatitude.Text)
			datrow("initiallongitude") = CDbl(cmbxinitiallongitude.Text)
			datrow("currentlattitude") = CDbl(txtcurrentlattitude.Text)
			datrow("currentlongitude") = CDbl(txtcurrentlongitude.Text)
			datrow("trackingdate") = CDate(datelab.Text)
			datrow("trackingtime") = CDate(timelabuct.Text)
			datset.Tables("gm862").Rows.Add(datrow)
			cmdb = New MySqlCommandBuilder(dataadapt)
			dataadapt.Update(datset, "gm862")
			datset.Clear()
			dataadapt.Fill(datset, "gm862")
			datatab = datset.Tables("gm862")
			cbxforename.Text = ""
			cbxsurename.Text = ""
			cmbxartifact.Text = ""
			txtimei.Text = ""
			cmbxintiallatitude.Text = ""
			cmbxinitiallongitude.Text = ""
			txtcurrentlongitude.Text = ""
			txtcurrentlongitude.Text = ""
			datelab.Text = ""
			timelabuct.Text = ""
			ButnNew.Enabled = True
			ButtnSave.Enabled = True
			cmbxGM862Findby.Enabled = True
		End If
	End Sub

is the problem related to date and the time? as i am using a label for the time and date, should i replace them by txtboxes?
waiting for ur help
Posted
Comments
Mahesh Bailwal 3-Jul-13 8:23am    
Press F5 once you get cursor on datadapt lines, then you will get some error.
Share that error.
fridrai raissi 3-Jul-13 8:26am    
thx for ur quick answer :)
no error message is mentionned, i just find the cursor blinking near dataadapt :O
Foothill 3-Jul-13 10:12am    
Try removing the "gm862". The select statement for the command object is already set. It could be confusing it. Just an idea.
Kschuler 3-Jul-13 10:13am    
I've never really used the parms that you are using with your .Fill statement. I'm wondering if the second parm, the string which you have as "gm862", could be the problem. That table doesn't exist in your DataSet until AFTER the fill is completed. Try removing that parm and see what happens. So you'd just have: dataadapt.Fill(datset)

1 solution

what's really ennoying me, is that the same code is working well on the users' subwindow, whenever i insert new data, the table is well updated :'(
here is the users' code, which works well!! wouldu like to tell me what's the difference?
VB.NET
Private Sub ButtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtnSaveU.Click
		ButnNewU.Enabled = True
		cmbxUFindby.Enabled = True
		sql = "select * from user"
		cmd = New MySqlCommand(sql)
		dataadapt = New MySqlDataAdapter(cmd)
		datset = New DataSet
		cmd.Connection() = cn
		dataadapt.Fill(datset, "user") 'dataadapter.Fill=remplir
		datatab = datset.Tables("user")
		If txtEmail.Text = "" Or txtname.Text = "" Or txtshrtname.Text = "" Or txtsecretan.Text = "" Or txtsecretq.Text = "" Or cmbxgovern.Text = "" Or cmbxmaritstat.Text = "" Or txtphone.Text = "" Or cmbxsex.Text = "" Or txtadress.Text = "" Then
			MsgBox("Please fill in all fields !", MsgBoxStyle.Information, "Information")
		Else
			datrow = datset.Tables("user").NewRow
			datrow("name") = txtname.Text
			datrow("shortname") = txtshrtname.Text
			datrow("address") = txtadress.Text
			datrow("phonenumber") = CInt(txtphone.Text)
			datrow("Secret_Question") = txtsecretq.Text
			datrow("Secret_Answer") = txtsecretan.Text
			datrow("email") = txtEmail.Text
			datrow("sex") = cmbxsex.Text
			datrow("maritalstatus") = cmbxmaritstat.Text
			datrow("country") = cmbxgovern.Text
			datset.Tables("user").Rows.Add(datrow)
			cmdb = New MySqlCommandBuilder(dataadapt)
			dataadapt.Update(datset, "user")
			datset.Clear()
			dataadapt.Fill(datset, "user")
			datatab = datset.Tables("user")
			txtEmail.Text = ""
			txtadress.Text = ""
			txtname.Text = ""
			txtshrtname.Text = ""
			txtsecretan.Text = ""
			txtsecretq.Text = ""
			cmbxsex.Text = ""
			cmbxgovern.Text = ""
			cmbxmaritstat.Text = ""
			txtphone.Text = ""
			ButnNewU.Enabled = True
			ButtnSaveU.Enabled = False
		End If
	End Sub
 
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