|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Heya Ppl,
I'm trying to plug two subroutines into a codebehind file...one to fire when the page is loaded, the other one gets triggered when a button is pressed on the display page. Thing is, when I run the page, it tries to run both subs at once...at least, that's the impression I'm getting. I'm getting an error message at Line 47 of bulkadd.vb (BC30105: Number of indices is less than the number of dimensions of the indexed array.). That shouldn't happen since the function isn't supposed to be triggered yet. Below is my code....I could REALLY use the help. Thanks in advance (BulkAdd.vb) Imports System Imports System.Data Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Data.SqlClient Public Class bulkadd Inherits Page Public maillist As DropDownList Public conPubs As Sqlconnection Public cmdSelect As SqlCommand Public dtrTitles As SqlDataReader Public sqlcmdstr As String Sub Page_Load conPubs = New SQLConnection("CONNECTION INFO") Dim company_id As Integer company_id= 5 sqlcmdstr= "SELECT title,list_table_name FROM m_mailing_list WHERE m_mailing_list.company_id='" & company_id & "'" cmdSelect= New SQLCommand (sqlcmdstr, conPubs) conPubs.Open() dtrTitles= cmdSelect.ExecuteReader() maillist.DataSource=dtrTitles maillist.DataValueField= "list_table_name" maillist.DataTextField= "title" maillist.DataBind() dtrTitles.Close() conPubs.Close() End Sub Sub address_add(s As Object, E As EventArgs) Dim badentries As String Dim newemailaddresses() As String conPubs = New SQLConnection("CONNECTION INFO") newemailaddresses()= split(bulkadd.text, "\n") Do While i < Ubound(newemailaddresses,2) sqlcmdstr= "SELECT email FROM " & maillist.value & " WHERE email= '" & newemailaddress(i) & "'" cmdSelect= New SQLCommand (sqlcmdstr, conPubs) conPubs.Open() dtrTitles= cmdSelect.ExecuteScalar() if dtrTitles.HasRows THEN badentries= newemailaddresses(i) & "\n" & badentries dtrTitles.Close() conPubs.Close() Else dtrTitles.Close() conPubs.Close() sqlcmdstr= "INSERT INTO " & maillist.value & " (email) VALUES ('" & newemailaddresses(i) & "')" cmdSelect= New SQLCommand (sqlcmdstr, conPubs) conPubs.Open() cmdSelect.ExecuteNonQuery() conPubs.Close() End If i=i+1 Loop 'Possibly stuff bad entries into label text End Sub End Class In case it helps, here's the front end as well (bulkadd.aspx) <%@ Page Inherits="bulkadd" Src="bulkadd.vb"%> <html> <form runat="server"> <asp:textbox id="bulkadd" textmode="multiline" cols="20" rows="5" runat="server" /> <asp ropDownListid="maillist" runat="server" /> <asp:Button text="BulkAdd" onClick="address_add" Runat="Server" /> </form> </body> </html> |
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Newbie ASP.NET Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|