查看: 902|回复: 4
|
请教sql 的问题
[复制链接]
|
|
请教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 )) |
|
|
|
|
|
|
|
发表于 2-11-2006 01:13 PM
|
显示全部楼层
1. 你的问题是什么?
2. 把出了问题的 code 放上来吧. |
|
|
|
|
|
|
|
楼主 |
发表于 2-11-2006 04:34 PM
|
显示全部楼层
- Private Sub getUser()
- Dim connection As IDbConnection = Nothing
- Try
- Try
- connection = getConnection(getConnectionString(gclsDBConfig))
- connection.Open()
- Catch ex As Exception
- MessageBox.Show("The connection with the database can't be established", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Exit Sub
- End Try
- Dim strSQL3 As String = "select distinct usrid from ZPUREQH"
- Dim ds1 As New DataSet
- Dim j As Integer = 0
- Dim k As Integer = 0
- Dim userarr As ValueList
- Dim str As String
- Dim ar As New ArrayList
- Dim sMonths() As String = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
- DBSQLHelper.FillDataset(connection, CommandType.Text, strSQL3, ds1, New String() {"t1"})
- For j = 0 To ds1.Tables("t1").Rows.Count - 1
- If frmTPR.IsValidDeptUser(ds1.Tables("t1").Rows(j).Item("usrid").ToString) = True Then
- str = ds1.Tables("t1").Rows(j).Item("usrid").ToString
- str = "'" & str & "','" & str & "'"
- 'ar.Add(str)
- 'userarr.ValueListItems.Add(str)
- End If
- Next
- Dim newstr As String = str
- Catch ex As Exception
- Dim errMessage As String = ""
- Dim tempException As Exception = ex
- While (Not tempException Is Nothing)
- errMessage += tempException.Message + Environment.NewLine + Environment.NewLine
- tempException = tempException.InnerException
- End While
- MessageBox.Show("Please check the following error messages: " + Environment.NewLine + errMessage, "Application error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Finally
- If Not connection Is Nothing Then
- CType(connection, IDisposable).Dispose()
- End If
- End Try
- End Sub
复制代码 |
|
|
|
|
|
|
|
楼主 |
发表于 2-11-2006 04:36 PM
|
显示全部楼层
form this query
- Dim strSQL As String = "SELECT '' AS TICK,H.REFNO,H.ISSDT,D.SUPPCD,H.ISSBY,H.REQBY,H.NEEDBY,H.USRID, " & _
- "D.TRNCD,D.COMID,D.DOCNO,D.LINENO,D.ITMCD,D.ITMDESC,D.RORDQTY,D.ORDQTY,D.APVLQTY,D.APVLDT, " & _
- "D.APVLQTY AS PrevAPVLQTY, D.APVLDT AS PrevAPVLDT, D.SUPPCD AS PrevSUPPCD " & _
- "FROM ZPUREQH H LEFT JOIN ZPUREQD D ON " & _
- "H.DOCNO=D.DOCNO AND H.TRNCD=D.TRNCD AND H.COMID=D.COMID " & _
- "WHERE COMID='" & gstrCOMID & "' " & _
- "AND TRNCD='" & coPRTrnCd & "' " & _
- "AND ISSDT > '" & gfFormatSQLDate(txtFIssDT.Text, gstrDTFMT) & "' " & _
- "AND ISSDT <='" & gfFormatSQLDate(CDate(Today), gstrDTFMT) & "' " & _
- "AND h.USRID IN ('" & strUser1 & "') "
- strSQL = strSQL & strSQL2
复制代码 |
|
|
|
|
|
|
|
发表于 3-11-2006 09:32 AM
|
显示全部楼层
第一个 code 和 第二个 code 有什么用途呢?
有 Error Message 吗?
很含糊的问题... 再解释清楚你的问题吧. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|