| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 725 人关注过本帖
标题:求数据库查询写数据
只看楼主 加入收藏
w314421717
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-10-14
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
求数据库查询写数据
Private Sub setE()
        Dim ccy As New SqlClient.SqlConnection
        Dim str As String = "server=192.168.186.1;uid=dba;pwd=Password;database=top"
        Dim cmd2 As New SqlClient.SqlCommand
        Dim tb2 As New DataTable
        Dim ada1 As New SqlClient.SqlDataAdapter
        ccy = New System.Data.SqlClient.SqlConnection(str)
        ccy.Open()
        Dim strsql2 = "SELECT BS,D,V,ZL,HH,(case when substring(D,1,1)='S' then JE*1 else JE*-1 end) as money,(case when substring(D,1,1)='S' then SL*1 else SL*-1 end) as SL,THBS,txdate FROM  typ"
         = strsql2
        cmd2.Connection = ccy
        ada1.SelectCommand = cmd2
        tb2.Clear()
        ada1.Fill(tb2)
        DataGridView1.DataSource = tb2
        DataGridView1.Refresh()
        DataGridView1.Visible = True
        Dim cmd3 As New SqlClient.SqlCommand
        Dim tb3 As New DataTable
        Dim ada12 As New SqlClient.SqlDataAdapter
        Dim strsql3 = "SELECT BS,D,V,ZL,HH,(case when substring(D,1,1)='S' then JE*1 else JE*-1 end) as money,(case when substring(D,1,1)='S' then SL*1 else SL*-1 end) as SL,THBS,txdate FROM typ"
         = strsql3
        cmd3.Connection = ccy
        ada12.SelectCommand = cmd3
        tb3.Clear()
        ada12.Fill(tb3)
        DataGridView2.DataSource = tb3
        DataGridView2.Refresh()
        DataGridView2.Visible = True
        ccy.Close()
    End Sub
我想将这2个查询结果写到192.168.186.2数据库topcs  DataGridView 写到数据库 或者查询值直接写入,本人不太懂这其中奥妙~!
搜索更多相关主题的帖子: 数据库查询 database server money 
2013-10-14 17:16
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:20 
顶一下
2013-10-14 18:35
快速回复:求数据库查询写数据
数据加载中...
 
   



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

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