Any assistance would be very much appreciated. Thanks.
Hmmm, ... where do you execute your command? It seems that you forgot the execution of the command.
Public Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
'Build list of message recipients
Dim dlItem As DataListItem
Dim Recipients As String
For Each dlItem In dtlAssocList.Items
Dim chbSelAssoc As CheckBox = CType(dlItem.FindControl("chbSelAssoc"), CheckBox)
If chbSelAssoc.Checked = True Then
Dim lblAssocCode As Label = CType(dlItem.FindControl("lblAssocCode"), Label)
Recipients += lblAssocCode.Text + ","
End If
Next dlItem'Check to see if the SelectAll checkbox is checked.
Dim SelectAll As String
If chbSelectAll.Checked = True Then
SelectAll = "1"
Else
SelectAll = "0"
End IfDim cnnConnection As System.Data.SqlClient.SqlConnection
Dim connString2 As String = ConfigurationSettings.AppSettings("connString2")
Dim cmdCommand As System.Data.SqlClient.SqlDataAdaptercnnConnection = New System.Data.SqlClient.SqlConnection(connString2)
cmdCommand = New System.Data.SqlClient.SqlDataAdapter("wpsp_MM_I_Message", cnnConnection)cmdCommand.SelectCommand.CommandType = CommandType.StoredProcedure
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.msg_title", SqlDbType.VarChar, 50))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.msg_title").Value = txbMsgTitle.Text
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.msg_text", SqlDbType.VarChar, 500))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.msg_text").Value = txbMessageText.Text
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.sendAll", SqlDbType.Bit, 1))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.sendAll").Value = SelectAll
cmdCommand.SelectCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@dotnet.itags.org.AssocList", SqlDbType.VarChar, 4000))
cmdCommand.SelectCommand.Parameters("@dotnet.itags.org.AssocList").Value = RecipientsResponse.Redirect("ManagersMessage.aspx")
End Sub
You are not aactually doing anything here. You are setting parameters, and then doing nothing. You never open the connection or fill a dataset or anything.
You should debug the application (if using VS.NET) or otherwise, you can use tracing or even Response.Write() to see where you are going.
What are you indending to do?
The 'wpsp_MM_I_Message' Stored Procedure takes the variables that I pass to it and then executes another Stored Procedure (behind the scenes).
What code do I need to include to get the 'wpsp_MM_I_Message' Stored Procedure to execute?
Presuming this returns no records:
Dim cnnConnection As System.Data.SqlClient.SqlConnection
Dim connString2 As String = ConfigurationSettings.AppSettings("connString2")
Dim cmdCommand As System.Data.SqlClient.SqlCommandcnnConnection = New System.Data.SqlClient.SqlConnection(connString2)
cmdCommand = New System.Data.SqlClient.SqlDataAdapter("wpsp_MM_I_Message", cnnConnection)cmdCommand.CommandType = CommandType.StoredProcedure
cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.msg_title", SqlDbType.VarChar, 50))
cmdCommand.Parameters("@.msg_title").Value = txbMsgTitle.Text
cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.msg_text", SqlDbType.VarChar, 500))
cmdCommand.Parameters("@.msg_text").Value = txbMessageText.TextcmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.sendAll", SqlDbType.Bit, 1))
cmdCommand.Parameters("@.sendAll").Value = SelectAll
cmdCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@.AssocList", SqlDbType.VarChar, 4000))
cmdCommand.Parameters("@.AssocList").Value = RecipientscmdCommand.ExecuteNonQuery()
Note cmdCommand is changed into a SqlCommand object rather than a SqldataAdapter
if it returns records, you could either create a SQLDataReader or a Dataset
That's what I needed. Thank you very much.
0 comments:
Post a Comment