| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:急用...
只看楼主 加入收藏
kelove
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-10-17
收藏
 问题点数:0 回复次数:0 
急用...

我的老是插不了数据库里面 错误是 已有打开的与此连接相关联的DATAreader,必须将它关闭 哪个高手帮帮忙..谢了 Dim ue As New UnicodeEncoding Dim pwd() As Byte = ue.GetBytes(txtpwd.Text) Dim sha As New SHA1Managed Dim pw() As Byte = sha.ComputeHash(pwd) Dim empid As Integer = FormListEmployee.empid

Dim modify As New SqlCommand Dim str As String = "UPDATE tblEmployee SET Name = @txtname, LoginName = @txtloginname, Password = @pwd, Email = @txtEmail, BasicSalary = @txtbasicsalary, EmployeeLevel = @numLevel, Title = @txttitle, Telephone = @txtphone, PhotoImage = @picPhoto WHERE (EmployeeID = @empid)" modify.CommandText = str modify.Connection = SqlConnection1 modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txtname", System.Data.SqlDbType.NVarChar, 50, "Name")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txtloginname", System.Data.SqlDbType.NVarChar, 20, "LoginName")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@pwd", System.Data.SqlDbType.VarBinary, 20, "Password")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txtEmail", System.Data.SqlDbType.NVarChar, 50, "Email")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txtbasicsalary", System.Data.SqlDbType.Int, 4, "BasicSalary")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@numLevel", System.Data.SqlDbType.Int, 4, "EmployeeLevel")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txttitle", System.Data.SqlDbType.NVarChar, 50, "Title")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@txtphone", System.Data.SqlDbType.NVarChar, 50, "Telephone")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@picPhoto", System.Data.SqlDbType.VarBinary, 16, "PhotoImage")) modify.Parameters.Add(New System.Data.SqlClient.SqlParameter("@empid", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "EmployeeID", System.Data.DataRowVersion.Original, Nothing)) ' modify.Parameters("@txtname").Value = txtname.Text modify.Parameters("@txtname").Direction = ParameterDirection.Input modify.Parameters("@txtloginname").Value = txtloginname.Text modify.Parameters("@txtloginname").Direction = ParameterDirection.Input modify.Parameters("@pwd").Value = pw modify.Parameters("@pwd").Direction = ParameterDirection.Input modify.Parameters("@txtEmail").Value = txtEmail.Text modify.Parameters("@txtEmail").Direction = ParameterDirection.Input modify.Parameters("@txtbasicsalary").Value = txtbasicsalary.Text modify.Parameters("@txtbasicsalary").Direction = ParameterDirection.Input modify.Parameters("@numLevel").Value = numLevel.Text modify.Parameters("@numLevel").Direction = ParameterDirection.Input modify.Parameters("@txttitle").Value = txttitle.Text modify.Parameters("@txttitle").Direction = ParameterDirection.Input modify.Parameters("@txtphone").Value = txtphone.Text modify.Parameters("@txtphone").Direction = ParameterDirection.Input Dim FormPhotoPath As New FormPhotoPath If File.Exists(FormPhotoPath.path) Then

Dim fs As FileStream = File.OpenRead(FormPhotoPath.path) Dim abytes() As Byte abytes = Array.CreateInstance(GetType(Byte), fs.Length) fs.Read(abytes, 0, fs.Length) modify.Parameters("@picPhoto").Value = abytes modify.Parameters("@picPhoto").Direction = ParameterDirection.Input

fs.Close() End If

modify.Parameters("@empid").Value = empid modify.Parameters("@empid").Direction = ParameterDirection.Input

Try SqlConnection1.Open()

If modify.ExecuteNonQuery Then MessageBox.Show("修改成功!", "提示") End If Catch ex As Exception MessageBox.Show("修改失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally If SqlConnection1.State = ConnectionState.Open Then

SqlConnection1.Close() End If End Try

End Sub

搜索更多相关主题的帖子: 数据库 modify Email 
2005-10-18 17:05
快速回复:急用...
数据加载中...
 
   



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

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