Advertisement
Advertisement
| 04.26.2008 at 05:22PM PDT, ID: 23356424 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: |
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class ExecutiveTest
Inherits System.Web.UI.Page
Public ForceConn As String
Public SEL, WHR As New StringBuilder()
Public LoadSQL As SqlConnection
Public LoadCommand As SqlDataAdapter
Public ocaLoad As New DataSet()
Protected WithEvents SqlStatusCommand As System.Data.SqlClient.SqlCommand
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ForceConn = ConfigurationManager.AppSettings("ForceConnectionString")
If Not Page.IsPostBack Then
Call initialize_form()
End If
End Sub
Sub initialize_form()
'load initial settings for dropdowns
Call load_dd1()
ddVPLev6.ClearSelection() : ddVPLev6.Items.Clear()
ddVPLev6.Items.Insert(0, "Waiting for data...") : ddVPLev6.Enabled = False
ddDirLev7.ClearSelection() : ddDirLev7.Items.Clear()
ddDirLev7.Items.Insert(0, "Waiting for data...") : ddDirLev7.Enabled = False
'clears gridview of all data
gvData.PageIndex = 0 : gvData.DataSource = Nothing
gvData.SelectedIndex = -1
End Sub
Sub load_dd1()
Dim LoadSQL As New SqlConnection(ForceConn)
'input name of store procedure on line below, in quotes
Dim myCommand As New SqlCommand("sp_getlevel6", LoadSQL)
myCommand.CommandType = CommandType.StoredProcedure
With myCommand
'used to select specific statement
.Parameters.Add(New SqlParameter("@INQ", SqlDbType.Int)).Value = 1
'list all variable of stored procedure and default value
.Parameters.Add(New SqlParameter("@categoryID", SqlDbType.Int)).Value = 0
.Parameters.Add(New SqlParameter("@parentID", SqlDbType.Int)).Value = 0
End With
Dim myDS As New DataSet()
Try
LoadSQL.Open()
LoadCommand = New SqlDataAdapter()
LoadCommand.Fill(myDS)
ddSVPLev5.ClearSelection() : ddSVPLev5.Items.Clear()
ddSVPLev5.DataSource = myDS
ddSVPLev5.DataBind()
'optional line, if want to get creative, but not required
ddSVPLev5.Items.Insert(0, "Select One")
LoadSQL.Close() : LoadSQL.Dispose()
Catch SQLexc As SqlException
testing.Text = SQLexc.ToString
If LoadSQL.State = ConnectionState.Open Then LoadSQL.Close()
LoadSQL.Dispose()
Exit Sub
End Try
End Sub
Sub load_dd2(ByVal parentID As Integer)
Dim LoadSQL As New SqlConnection(ForceConn)
'input name of store procedure on line below, in quotes
Dim myCommand As New SqlCommand("sp_dropdowns", LoadSQL)
myCommand.CommandType = CommandType.StoredProcedure
With myCommand
'used to select specific statement
.Parameters.Add(New SqlParameter("@INQ", SqlDbType.Int)).Value = 2
'list all variable of stored procedure and default value
.Parameters.Add(New SqlParameter("@categoryID", SqlDbType.Int)).Value = 0
.Parameters.Add(New SqlParameter("@parentID", SqlDbType.Int)).Value = parentID
End With
Dim myDS As New DataSet()
Try
LoadSQL.Open()
LoadCommand = New SqlDataAdapter(myCommand)
LoadCommand.Fill(myDS)
ddVPLev6.ClearSelection() : ddVPLev6.Items.Clear()
ddVPLev6.DataSource = myDS
ddVPLev6.DataBind()
'optional line, if want to get creative, but not required
ddVPLev6.Items.Insert(0, "Select One")
LoadSQL.Close() : LoadSQL.Dispose()
Catch SQLexc As SqlException
testing.Text = SQLexc.ToString
If LoadSQL.State = ConnectionState.Open Then LoadSQL.Close()
LoadSQL.Dispose()
Exit Sub
End Try
End Sub
Sub load_dd3(ByVal categoryID As Integer, ByVal parentID As Integer)
Dim LoadSQL As New SqlConnection(ForceConn)
'input name of store procedure on line below, in quotes
Dim myCommand As New SqlCommand("sp_dropdowns", LoadSQL)
myCommand.CommandType = CommandType.StoredProcedure
With myCommand
'used to select specific statement
.Parameters.Add(New SqlParameter("@INQ", SqlDbType.Int)).Value = 3
'list all variable of stored procedure and default value
.Parameters.Add(New SqlParameter("@categoryID", SqlDbType.Int)).Value = categoryID
.Parameters.Add(New SqlParameter("@parentID", SqlDbType.Int)).Value = parentID
End With
Dim myDS As New DataSet()
Try
LoadSQL.Open()
LoadCommand = New SqlDataAdapter(myCommand)
LoadCommand.Fill(myDS)
DDDirLev7.ClearSelection() : DDDirLev7.Items.Clear()
DDDirLev7.DataSource = myDS
DDDirLev7.DataBind()
'optional line, if want to get creative, but not required
DDDirLev7.Items.Insert(0, "Select One")
LoadSQL.Close() : LoadSQL.Dispose()
Catch SQLexc As SqlException
testing.Text = SQLexc.ToString
If LoadSQL.State = ConnectionState.Open Then LoadSQL.Close()
LoadSQL.Dispose()
Exit Sub
End Try
End Sub
Protected Sub ddSVPLev5_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddSVPLev5.SelectedIndexChanged
'reset for list 3 since it's dependent on list 2 which is yet to be chosen
DDDirLev7.ClearSelection() : DDDirLev7.Items.Clear()
DDDirLev7.Items.Insert(0, "Waiting for data...") : DDDirLev7.Enabled = False
'if statement only necessary if using [ddSVPLev5.Items.Insert(0, "Select One")]
If ddSVPLev5.SelectedIndex = 0 Then
DDVPLev6.ClearSelection() : DDVPLev6.Items.Clear()
DDVPLev6.Items.Insert(0, "Waiting for data...") : DDVPLev6.Enabled = False
Exit Sub
End If
DDVPLev6.Enabled = True
Call load_dd2(CInt(ddSVPLev5.SelectedValue))
End Sub
Protected Sub ddVPLev6_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDVPLev6.SelectedIndexChanged
'if statement only necessary if using [ddVPLev6.Items.Insert(0, "Select One")]
If DDVPLev6.SelectedIndex = 0 Then
DDDirLev7.ClearSelection() : DDDirLev7.Items.Clear()
DDDirLev7.Items.Insert(0, "Waiting for data...") : DDDirLev7.Enabled = False
Exit Sub
End If
DDDirLev7.Enabled = True
Call load_dd3(CInt(DDVPLev6.SelectedValue), CInt(ddSVPLev5.SelectedValue))
End Sub
Protected Sub btnLeaderFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLeaderFilter.Click
'formats statement pieces
Call build_query()
'queries SQL for combined statement
Call load_data()
End Sub
Sub build_query()
'resets strings to nothing
SEL.Length = 0 : WHR.Length = 0
SEL.Append("SELECT column1, column2, column3 FROM testTable")
'temporary holders for the 3 dropdownlists
Dim WHR1, WHR2, WHR3 As New StringBuilder()
WHR1.Length = 0 : WHR2.Length = 0 : WHR3.Length = 0
'if statement only necessary if using [ddSVPLev5.Items.Insert(0, "Select One")]
If ddSVPLev5.SelectedIndex > 0 Then
WHR1.Append("column1 = " & ddSVPLev5.SelectedValue)
End If
'if statement only necessary if using [ddVPLev6.Items.Insert(0, "Select One")]
If DDVPLev6.SelectedIndex > 0 Then
WHR2.Append("column2 = " & DDVPLev6.SelectedValue)
End If
'if statement only necessary if using [ddDirLev7.Items.Insert(0, "Select One")]
If DDDirLev7.SelectedIndex > 0 Then
WHR3.Append("column3 = " & DDDirLev7.SelectedValue)
End If
If WHR1.Length > 0 Or WHR2.Length > 0 Or WHR3.Length > 0 Then
WHR.Append(" WHERE ")
Dim HLD As String = "" 'used for adding AND clause
If WHR1.Length > 0 Then WHR.Append(WHR1.ToString) : HLD = " AND "
If WHR2.Length > 0 Then WHR.Append(HLD & WHR2.ToString) : HLD = " AND "
If WHR3.Length > 0 Then WHR.Append(HLD & WHR3.ToString)
End If
End Sub
Sub load_data()
Dim LoadSQL As New SqlConnection(ForceConn)
Dim myCommand As New SqlCommand("SP_Sample", LoadSQL)
myCommand.CommandType = CommandType.StoredProcedure
With myCommand
.Parameters.Add(New SqlParameter("@selectSTR", SqlDbType.NVarChar, 2000)).Value = SEL.ToString
.Parameters.Add(New SqlParameter("@whereSTR", SqlDbType.NVarChar, 2000)).Value = WHR.ToString
End With
Dim myDS As New DataSet()
Try
LoadSQL.Open()
LoadCommand = New SqlDataAdapter(myCommand)
LoadCommand.Fill(myDS)
gvData.DataSource = myDS
gvData.DataBind()
LoadSQL.Close() : LoadSQL.Dispose()
Catch SQLexc As SqlException
testing.Text = SQLexc.ToString
If LoadSQL.State = ConnectionState.Open Then LoadSQL.Close()
LoadSQL.Dispose()
Exit Sub
End Try
End Sub
End Class
|