首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

vb.net update 方面有关问题.

2012-02-02 
vb.netupdate 方面问题...Me.connNewSystem.Data.SqlClient.SqlConnectionDimCmAsNewSqlClient.SqlComman

vb.net update 方面问题...
Me.conn   =   New   System.Data.SqlClient.SqlConnection
                Dim   Cm   As   New   SqlClient.SqlCommand
                Dim   strUpdatename   As   String   =   "update   yonghu   set   (id= ' "   +   Me.TextBox1.Text   +   " '),(psw= ' "   +   Me.TextBox3.Text   +   " ')   where   (id= ' "   +   Me.TextBox1.Text   +   " ') "
             

                If   TextBox2.Text   =   TextBox3.Text   Then

                        Me.conn.ConnectionString   =   "workstation   id= " "EASYSOFT-2CA1DB " ";packet   size=4096;integrated   security=SSPI;initia "   &   _
                    "l   catalog=myfirstdb;persist   security   info=False "
                        Cm.Connection   =   conn
                        Cm.CommandText   =   strUpdatename
                        MessageBox.Show( "密码修改成功! ",   "student-system ",   MessageBoxButtons.OK,   MessageBoxIcon.Information)
                        conn.Close()
                        Me.Close()
                Else
                        System.Windows.Forms.MessageBox.Show( "密码确认失败! ",   "student-system ",   MessageBoxButtons.OK,   MessageBoxIcon.Information)

                End   If


以上这些就是我的代码.为什么老是更新不了数据库里数据.数据库表名为     yonghu
字段就两个     id     psw         ,窗口为三个输入筐,用户,新密码,确认密码
请高手指点......

[解决办法]
Cm.Connection = conn
if conn.state=Closed then conn.open()
Cm.CommandText = strUpdatename
Cm.ExecuteNonQuery
这样就好了

热点排行