| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 505 人关注过本帖
标题:数据记录插入问题
只看楼主 加入收藏
dyxg041
Rank: 2
等 级:论坛游民
帖 子:19
专家分:17
注 册:2006-5-15
收藏
 问题点数:0 回复次数:1 
数据记录插入问题

insert 语句运放到查询分析器里能正常运行 在 VB.NET下不能运行 望赐教,感激不尽!!
worker 表结构如附件

代码如下:
Me.birthday.Format = DateTimePickerFormat.Short
Me.Label36.Text = ""
If Me.txtdepartment.Text.Trim = "" Then
Me.Label36.Text = ""
Me.Label36.Text = "部门不能为空"
Exit Sub
ElseIf txtID.Text.Trim = "" Then
Me.Label36.Text = ""
Me.Label36.Text = "职工编号不能为空"
Exit Sub
ElseIf TxtName.Text.Trim = "" Then
Me.Label36.Text = ""
Me.Label36.Text = "职工姓名不能为空"
Exit Sub
Else
Dim marr As String
If Me.cbomarriage.Text = "未婚" Then
marr = 1
ElseIf Me.cbomarriage.Text = "已婚" Then
marr = 2
ElseIf Me.cbomarriage.Text = "离异" Then
marr = 3
Else
marr = 4
End If

Me.Label36.Text = ""
com.CommandText = "insert worker (id,name,sex, " & _
"birthdate,education,school,nation,polity,specialty, " & _
"place,marriage,address,postalcode,email,phone,idcard, " & _
"post,duty,dutystatus,department,foreignlevel,languagetype, " & _
"computerlevel,bankcard,bank,safetycard,startworkdate, " & _
"lengthservice,paylevel,intime,outtime,ownlengthservice, " & _
"startpactdate,endpactdate) " & _
"values(" & txtID.Text.Trim & ",'" & TxtName.Text.Trim & "', " & _
"'" & Me.CboSex.Text.Trim & "'," & Me.birthday.Text.Trim & ", " & _
"'" & Me.txtEducation.Text.Trim & "','" & Me.txtschool.Text.Trim & "', " & _
"'" & Me.TxtNation.Text.Trim & "','" & Me.Cbopolity.Text.Trim & "', " & _
"'" & Me.txtSpecial.Text.Trim & "','" & Me.txtPlace.Text.Trim & "', " & _
"" & marr & ",'" & Me.txtaddress.Text.Trim & "'," & Me.txtpostalcode.Text.Trim & ", " & _
"'" & Me.txtEmail.Text.Trim & "'," & Me.txtphone.Text.Trim & ", " & _
"" & Me.txtidCard.Text.Trim & ",'" & Me.txtpost.Text.Trim & "', " & _
"'" & Me.txtduty.Text.Trim & "','" & Me.txtdutystatus.Text.Trim & "', " & _
"'" & Me.txtdepartment.Text.Trim & "','" & Me.txtfroeignlevel.Text.Trim & "', " & _
"'" & Me.txtlanguagetype.Text.Trim & "','" & Me.txtcomputerlevel.Text.Trim & "', " & _
"" & Me.txtbankcard.Text.Trim & ",'" & Me.txtbank.Text.Trim & "', " & _
"" & Me.txtsafetycard.Text.Trim & "," & Me.txtstartworkdate.Text.Trim & ", " & _
"" & Me.txtlengthservice.Text.Trim & "," & Me.txtpaylevel.Text.Trim & ", " & _
"" & Me.txtintime.Text.Trim & "," & Me.txtouttime.Text.Trim & ", " & _
"" & Me.txtownlengthservic.Text.Trim & "," & Me.txtstartworkdate.Text.Trim & ", " & _
"" & Me.txtendpactdate.Text.Trim & ")"
Try
con.Open()
com.ExecuteNonQuery()
con.Close()
MessageBox.Show("记录添加成功", "提示消息", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
If con.State = ConnectionState.Open Then
con.Close()
MessageBox.Show("记录添加失败", "提示消息", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Exit Sub
End Try

End If


搜索更多相关主题的帖子: 数据记录 
2006-05-23 10:24
Tailor
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2005-6-26
收藏
得分:0 
程序怎么不加入必要的注释呢.让别人不容易看,在程序中最好不要用换行符,那样会使程序不容易读.最好用"&="进行连接.

2006-05-23 13:32
快速回复:数据记录插入问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019336 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved