| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 979 人关注过本帖
标题:使用向导连接ASSECC数据库时connection ,dataadapter ,dataview,dataset ...
只看楼主 加入收藏
smy727
Rank: 2
等 级:论坛游民
帖 子:95
专家分:20
注 册:2012-1-20
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:2 
使用向导连接ASSECC数据库时connection ,dataadapter ,dataview,dataset,currencymanager怎么表示的?怎
使用向导连接ASSECC数据库时connection ,dataadapter ,dataview,dataset,currencymanager怎么表示的?怎么调用?
搜索更多相关主题的帖子: 数据库 
2013-04-01 20:47
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:20 
关注

DO IT YOURSELF !
2013-04-01 21:13
kangtroo
Rank: 2
等 级:论坛游民
威 望:1
帖 子:21
专家分:25
注 册:2008-7-11
收藏
得分:0 
程序代码:
Imports System.Data
Imports System.Data.OleDb
Module Moddata
    Dim constr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\172.31.199.28\public\共享文档\data\考勤注册码.mdb"
    Dim conn As OleDbConnection

#Region "填充返回dataset"
    Public Function mydataset(ByVal sqlstr As String) As DataSet
        Try
            conn = New OleDbConnection(constr)
            conn.Open()
            Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlstr, conn)
            Dim ds As DataSet = New DataSet
            da.Fill(ds)
            Return ds
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "提示")
        Finally
            conn.Close()
        End Try


    End Function


#End Region
#Region "执行SQL语句"
    Public Sub exesqlcommand(ByVal sqlstr As String)
        Try
            conn = New OleDbConnection(constr)
            conn.Open()
            Dim sqlcmd As OleDbCommand
            sqlcmd = New OleDbCommand(sqlstr, conn)
            sqlcmd.ExecuteNonQuery()
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "提示")
        Finally
            conn.Close()
        End Try
    End Sub
#End Region
#Region "执行统计"
    Public Function exesqlscalar(ByVal sqlstr As String) As Integer
        Try
            conn = New OleDbConnection(constr)
            conn.Open()
            Dim sqlsc As OleDbCommand
            Dim sqlcount As Integer
            sqlsc = New OleDbCommand(sqlstr, conn)
            sqlcount = sqlsc.ExecuteNonQuery()
            exesqlscalar = sqlcount
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "提示")
        Finally
            conn.Close()
        End Try
    End Function
#End Region

#Region "数据读取返回单一字段值"
    Public Function exesqlreader(ByVal sqlstr As String) As String
        Try
            Dim myread As OleDbDataReader
            conn = New OleDbConnection(constr)
            conn.Open()
            Dim sqlcmd As OleDbCommand
            sqlcmd = New OleDbCommand(sqlstr, conn)
            myread = sqlcmd.ExecuteReader
            myread.Read()
            exesqlreader = myread.Item(0)
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Information, "提示")
        Finally
            conn.Close()
        End Try
    End Function
#End Region

End Module
最普遍的数据库连接方法 。只需改下数据库地址就行。。使用的时候,直接调用
上面的代码可以直接定成一个vb类。
下面给出查询、增加、跟修改的使用
程序代码:
 Dim mytable As DataTable = mydataset("select * from data where 店铺名称= '" & idflag & "'").Tables(0)
        Me.Tname.Text = idflag
        Tnum.Text = mytable.Rows(0).Item(0).ToString
        Tkjh.Text = mytable.Rows(0).Item(2).ToString
        Ttel.Text = mytable.Rows(0).Item(3).ToString
        Tqqm.Text = mytable.Rows(0).Item(4).ToString
        Tzcm.Text = mytable.Rows(0).Item(5).ToString   Call exesqlcommand("insert into data(店铺名称,联系电话,卡机号,软件请求码,注册码)values ('" & name1 & "','" & tel & "','" & kjh & "','" & qqm & "', '" & zcm & "')")
        MsgBox("增加成功", MsgBoxStyle.Information, "提示") Call exesqlcommand("update data set 店铺名称='" & name1 & "',联系电话='" & tel & "',卡机号='" & kjh & "', 软件请求码='" & qqm & "',注册码='" & zcm & "' where ID =" & num)
        MsgBox("更新成功 ", MsgBoxStyle.Information, "提示")


2013-04-23 16:02
快速回复:使用向导连接ASSECC数据库时connection ,dataadapter ,dataview,da ...
数据加载中...
 
   



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

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