| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1033 人关注过本帖
标题:VB.NET數據編程 急!!!!!!!
只看楼主 加入收藏
理想
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-1-9
收藏
 问题点数:0 回复次数:2 
VB.NET數據編程 急!!!!!!!
中對數據庫編程真的好難嗎?
那位大蝦有這個方面的資料或是代碼可以分享一下嗎
多謝:
搜索更多相关主题的帖子: NET 
2005-01-09 16:06
jframe
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-1-19
收藏
得分:0 
我刚学
不知道你在说什么
不过以我非常有限的知识觉得
添加 修改  删除  数据很容易
以下代码直接复制既可用

dim strConnect as string
strConnect = "Provider=SQLOLEDB;User ID=sa;password=;database=数据库;server=服务器"

Private Sub Add()
        Try
            Dim conn3 As New OleDb.OleDbConnection(strConnect)
            Dim da1 As New OleDb.OleDbDataAdapter
            Dim com1 As New OleDb.OleDbCommand("insert AdminEmployee values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & cmb1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')", conn3)
             da1.InsertCommand = com1
            com1.Connection.Open()
            com1.ExecuteNonQuery()
            com1.Connection.Close()
            MsgBox("添加成功", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("Somethinsg worng " & ex.ToString)
        End Try
    End Sub
     '-------------------------------------------
    Private Sub Delete()
        Try
            Dim conn4 As New OleDb.OleDbConnection(strConnect)
            Dim da1 As New OleDb.OleDbDataAdapter
            Dim com2 As New OleDb.OleDbCommand("Delete From AdminEmployee where ID='" & TextBox1.Text & "'", conn4)
          da1.DeleteCommand = com2
            com2.Connection.Open()
            com2.ExecuteNonQuery()
            com2.Connection.Close()
            MsgBox("删除成功", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("Somethinsg worng " & ex.ToString)
        End Try
    End Sub
    '------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Manage()
    Try
            Dim conn5 As New OleDb.OleDbConnection(strConnect)
            Dim da As New OleDb.OleDbDataAdapter
            Dim com3 As New OleDb.OleDbCommand("update AdminEmployee set Name ='" & TextBox2.Text & "',Address ='" & TextBox3.Text & "',Phone='" & TextBox4.Text & "',Email='" & TextBox5.Text & "',PostCard='" & TextBox6.Text & "',Position='" & cmb1.Text & "' where ID = '" & TextBox1.Text & "'", conn5)
           da.UpdateCommand = com3
            com3.Connection.Open()
            com3.ExecuteNonQuery()
            com3.Connection.Close()
            MsgBox("修改成功", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox("系统发生错误,请确定操作正确!" & ex.ToString, MsgBoxStyle.Critical)
        End Try
    End Sub

[此贴子已经被作者于2005-1-19 12:11:33编辑过]



2005-01-19 10:52
火狐
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2005-1-18
收藏
得分:0 
条件查询比较难哈!

21世纪什么最贵? 人才!
2005-01-20 20:18
快速回复:VB.NET數據編程 急!!!!!!!
数据加载中...
 
   



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

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