佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 882|回复: 4

请教sql 的问题

[复制链接]
发表于 1-11-2006 05:08 PM | 显示全部楼层 |阅读模式
请教sql 的问题   高手请进来!谢

i want to put the result of select statment into array vb.net

1) select distinct user from zuser  ----> array

2) select * from group where zuser in (arr(0,1,2,3 ))
回复

使用道具 举报


ADVERTISEMENT

发表于 2-11-2006 01:13 PM | 显示全部楼层
1. 你的问题是什么?
2. 把出了问题的 code 放上来吧.
回复

使用道具 举报

 楼主| 发表于 2-11-2006 04:34 PM | 显示全部楼层


  1. Private Sub getUser()
  2.         Dim connection As IDbConnection = Nothing
  3.         Try


  4.             Try
  5.                 connection = getConnection(getConnectionString(gclsDBConfig))
  6.                 connection.Open()
  7.             Catch ex As Exception
  8.                 MessageBox.Show("The connection with the database can't be established", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  9.                 Exit Sub
  10.             End Try

  11.             Dim strSQL3 As String = "select distinct usrid from ZPUREQH"
  12.             Dim ds1 As New DataSet
  13.             Dim j As Integer = 0
  14.             Dim k As Integer = 0
  15.             Dim userarr As ValueList
  16.             Dim str As String
  17.             Dim ar As New ArrayList

  18.             Dim sMonths() As String = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}

  19.             DBSQLHelper.FillDataset(connection, CommandType.Text, strSQL3, ds1, New String() {"t1"})
  20.             For j = 0 To ds1.Tables("t1").Rows.Count - 1
  21.                 If frmTPR.IsValidDeptUser(ds1.Tables("t1").Rows(j).Item("usrid").ToString) = True Then
  22.                     str = ds1.Tables("t1").Rows(j).Item("usrid").ToString
  23.                     str = "'" & str & "','" & str & "'"
  24.                     'ar.Add(str)

  25.                     'userarr.ValueListItems.Add(str)

  26.                 End If
  27.             Next

  28.             Dim newstr As String = str


  29.         Catch ex As Exception
  30.             Dim errMessage As String = ""
  31.             Dim tempException As Exception = ex

  32.             While (Not tempException Is Nothing)
  33.                 errMessage += tempException.Message + Environment.NewLine + Environment.NewLine
  34.                 tempException = tempException.InnerException
  35.             End While

  36.             MessageBox.Show("Please check the following error messages: " + Environment.NewLine + errMessage, "Application error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  37.         Finally
  38.             If Not connection Is Nothing Then
  39.                 CType(connection, IDisposable).Dispose()
  40.             End If
  41.         End Try
  42.     End Sub


复制代码
回复

使用道具 举报

 楼主| 发表于 2-11-2006 04:36 PM | 显示全部楼层
form this query


  1. Dim strSQL As String = "SELECT '' AS TICK,H.REFNO,H.ISSDT,D.SUPPCD,H.ISSBY,H.REQBY,H.NEEDBY,H.USRID, " & _
  2.                                 "D.TRNCD,D.COMID,D.DOCNO,D.LINENO,D.ITMCD,D.ITMDESC,D.RORDQTY,D.ORDQTY,D.APVLQTY,D.APVLDT, " & _
  3.                                 "D.APVLQTY AS PrevAPVLQTY, D.APVLDT AS PrevAPVLDT, D.SUPPCD AS PrevSUPPCD " & _
  4.                                 "FROM ZPUREQH H LEFT JOIN ZPUREQD D ON " & _
  5.                                 "H.DOCNO=D.DOCNO AND H.TRNCD=D.TRNCD AND H.COMID=D.COMID " & _
  6.                                 "WHERE COMID='" & gstrCOMID & "' " & _
  7.                                 "AND TRNCD='" & coPRTrnCd & "' " & _
  8.                                 "AND ISSDT > '" & gfFormatSQLDate(txtFIssDT.Text, gstrDTFMT) & "' " & _
  9.                                 "AND ISSDT <='" & gfFormatSQLDate(CDate(Today), gstrDTFMT) & "' " & _
  10.                                 "AND h.USRID IN ('" & strUser1 & "') "
  11.             strSQL = strSQL & strSQL2

复制代码
回复

使用道具 举报

发表于 3-11-2006 09:32 AM | 显示全部楼层
第一个 code 和 第二个 code 有什么用途呢?
有 Error Message 吗?

很含糊的问题... 再解释清楚你的问题吧.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 24-9-2024 01:26 AM , Processed in 0.103170 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表