我的按钮保存代码有什么问题? [英] what's the problem on my button save code?

查看:54
本文介绍了我的按钮保存代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人,

我的保存按钮出现问题:与另一个表更新(帐户)相同的代码运行良好,但文章的一个被阻止,我不知道不知道为什么,每次我填写组合框和文本框然后点击保存按钮,它运行nomore,当我回到我的edi visual studio上的源代码时,我发现光标在datadapt线上闪烁,

这里是代码:

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:

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



是与日期和时间有关的问题?因为我在时间和日期使用标签,我应该用txtbox替换它们吗?

等待你的帮助


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

推荐答案

真的是什么令我高兴的是,相同的代码在用户的子窗口上运行良好,每当我插入新数据时,表格都会更新:'(

这里是用户的代码,效果很好! !wouldu想告诉我有什么区别?

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?
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


这篇关于我的按钮保存代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆