你能解释一下我能用母版页的组合框做什么吗?我在组合框中设置数据库名称,我通过子页面调用代码如下尝试
sqlConn = New SqlConnection(strConn)
sqlConn.Open()
Dim sqlda1 As SqlClient.SqlDataAdapter
Dim sqlds1 As New DataSet
sqlQry = "EXEC sp_databases"
sqlda1 = New SqlDataAdapter(sqlQry, sqlConn)
sqlda1.Fill(sqlds1, "DataBaseList")
sqlConn.Close()
Session.Add("dscb", " ")
Session.Add("dscb", sqlds1.Tables("DataBaseList"))
Dim IntPCount As Integer
IntPCount = sqlds1.Tables("DataBaseList").Rows.Count
'IntPCount = Session("dscb")
Dim PCol As String
' cbDataBaseList.Items.Clear()
cbDataBaseList.Items.Clear()
cbDataBaseList.Text = "Select"
For p = 0 To IntPCount - 1
PCol = sqlds1.Tables("DataBaseList").Rows(p).Item("DATABASE_NAME").ToString
If PCol.Length > 5 Then
If PCol <> "master" Or PCol <> "msdb" Or PCol <> "tempdb" Then
Dim strDataBaseName As String = PCol
strDataBaseName = strDataBaseName.Remove(4)
'*** Add only "Customer's" which got the prefix "CLT_ " ***
If strDataBaseName = "CLT_" Then
NewPCol = PCol.Replace("CLT_", "")
NewPCol.Trim()
'cbDataBaseList.Items.Add(NewPCol)
cbDataBaseList.Items.Add(NewPCol)
End If
End If
End If
Next
Session.Add("CMBID", "")
'cbDataBaseList.Text = NewPCol.ToString
sqlds1.Dispose()
Catch ex As Exception
strex = ex.Message
'MessageBox.Show(strex, "General form exception message 5.", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
选择索引更改事件
会话(“CMBID”)= cbDataBaseList.Text