Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by kwilliams

  1. I created a simple Stored Procedure (SP) that queries a table and renames the column names, and I'm able to push those results out to a CSV file *with* those header names when done manually.But when I try to export the results to a CSV file by running the same SP using xp_cmdshell with bcp, the header row (Col1, Col2, and Col3) does not appear in the resulting CSV file.ORIGINAL TABLE:ColumnName1-----ColumnName2-----ColumnName3Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianQUERY WITHIN SP:SELECT ColumnName1 AS Col1, ColumnName2 AS Col2, ColumnName3 AS Col3FROM TABLENAMEQUERY RESULT:Col1-----Col2-----Col3 <<<<----- WHAT I WANT!Joe Schmo CustomerJane Doe CustomerTiny Tim MusicianHere's the code I'm using within the job:EXEC xp_cmdshell 'bcp "EXEC DATABASENAME.dbo.STOREDPROCEDURENAME" QUERYOUT "\\MYSERVERNAME\files\export.csv" -c -t, -T -S'CSV FILE RESULT USING BCP:Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianAs you can see the headers are missing. What am I doing wrong?

  2. I recently got a new machine that runs Windows 7 Professional with 64-bit OS. I re-installed several programs, and tried to install SQL Server 2000 without success. I was told that it wasn't compatible with Windows 7, but that I could download MS's "SQL Server 2000 DTS Designer Components" to manage old DTS packages.This worked great a first for several weeks, and then blamo, it just stopped working for no reason. I can view all of the DTS packages with SQL Server 2005 under SERVERNAME > Management > Legacy > Data Transformation Services, but as soon as I try to open one, I get this error:------------------------------TITLE: Object ExplorerThis package cannot be edited.SQL Server 2000 DTS Designer components are required to edit DTS packages. Install the special Web download, "SQL Server 2000 DTS Designer Components" to use this feature.If the "SQL Server 2000 DTS Designer Components" download is already installed, there might be a problem with the compatibility of icons persisted in this DTS package. See the following KB article for more details: http://support.microsoft.com/kb/917406 (Microsoft.SqlServer.DtsObjectExplorerUI)------------------------------First off, I made sure that "SQL Server 2000 DTS Designer Components" is already installed on my machine several times via the Add/Remove Programs list. I then followed the steps on the KB article at http://support.microsoft.com/kb/917406 without success. I cannot insert the SQL Server 2000 CD into my system, as I get an immediate error about incompatibility.Has this happened to anyone else here? If so, what should I do? I've tried uninstalling and reinstalling these related components to no avail, and I'm at a loss as to why it would work before and not now. Any and all help is greatly appreciated.

    • Like 1

  3. I thought that posting my solution might help others, so here it goes:After getting some advice from another forum user, I was able to solve the problem by taking a step back. I did that by using a simple example of the ArrayList at W3Schools at http://www.w3schools.com/aspnet/aspnet_arraylist.asp to compare it to my code. The issue ended up being in the page declaration. I had EnableViewState="false", and I changed it to EnableViewState="true". Once I did that, and I placed the initial code within an "If Not Page.IsPostBack Then...", it worked as it should. :good:

  4. I'm having a problem getting the selected value from a DropDownList that uses an ArrayList as a DataSource. When I select a year and click on the submit button, I get the following error message: Object reference not set to an instance of an object. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. I'm not understanding why this isn't working. The years (1900 - 1993) are getting populated into the DropDownList without a problem, but on the btnSubmit_Click job gets submitted, I get that error. And and all help would be appreciated. Hopefully it's something simple that I'm missing. Here's the code I'm using: VB.NET CODE-BEHIND:

    'Assign date variables	Dim dtCurrDate As DateTime = DateTime.Now 'Assign current date	Dim intCurrYear As Integer = DateTime.Now.Year 'Assign current year	Dim intVotingYear As Integer = intCurrYear - 18 'Assign voting year Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles Me.Load 	If Not Page.IsPostBack Then 'loads with page 			'Declare an array for the dynamic dropdownlist			Dim colArrayList As New System.Collections.ArrayList() 			'Declare loop variables			Dim i As Integer = 1900			Dim intDisplayYear As Integer = i 			'Loop through years			For i = 1900 To intVotingYear				colArrayList.Add(i)				colArrayList.TrimToSize()				colArrayList.Sort() 'Sort years				colArrayList.Reverse() 'Reverse sort/descending order			Next 			'Bind data			ddlYear.DataSource = colArrayList			ddlYear.DataBind() 			'Add a new listitem to the beginning of the dropdownlist			ddlYear.Items.Insert(0, New ListItem("- Year -", "")) 'Text, value			ddlYear.SelectedIndex = ddlYear.Items.IndexOf(ddlYear.Items.FindByText(Session("SelectedYear"))) 		End If End Sub Sub btnSubmit_Click(ByVal Sender As Object, ByVal E As EventArgs) 	'Declare form variables	Dim strFormYear As String = ddlYear.SelectedItem.Text '<<<<-----THIS IS WHERE I GET THE ERROR 	'NOTE: I've also tried changing the above line to:	'Dim strFormYear As String = ddlYear.SelectedItem.Value	'...but that resulted in the same error. 	'Declare session variables	Session("SelectedYear") = dob_year_form 	If Page.IsValid Then		Try...		...	End If End Sub


    <form id="form1" method="post" runat="server"> 	<asp:DropDownList id="ddlYear" runat="server"></asp:DropDownList> 	<asp:Button ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" runat="server" /> </form>

  5. To make it easier for users to get to a section of our site, we created a virtual directory alias which redirects the user to a specific web page. If there's no virtual directory for http://www.mysite.com/subdirectory/webpage.aspx, then that Master Page reference works fine. But once I created a virtual directory and attempted to get to that same page by typing the path to the virtual directory (http://www.mysite.com/subdirectory), I received this error message relating to the web page trying to access our site's Master Page, which is located in the root of the site:Server Error in '/subdirectory' Application.Parser ErrorDescription: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.Parser Error Message: The file '/subdirectory/MasterPage.master' does not exist.Source Error:Line 1: <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" EnableSessionState="true" EnableViewState="false" Title="Web Page" %>Source File: /subdirectory/webpage.aspx Line: 1I've tried changing the "~/MasterPage.master" reference to "./MasterPage.master" (one period), "../MasterPage.master" (two periods), "/MasterPage.master" (no tilde before slash), and "MasterPage.master" (just the file name) to no avail! Does anyone here know how I can fix this?These are two sites that contain steps on what we did:http://www.microsoft.com/technet/prodtechn...2.mspx?mfr=true (under "Virtual Directories")http://www.beansoftware.com/ASP.NET-Tutori...IS-ASP.NET.aspx (under "How to create the virtual directory on the web server")

  6. I have AutoPostBack set to "true" for a few dropdownlists on my form. Every time that I set this property to true, the page takes 4-5 seconds to load that dropdownlist, no matter what code is located within the Page_Load event.Even if I create a completely fresh page with absolutely no codebehind, it still takes that long to reload the page. This becomes a problem with any applications, because if a user selects 3 options quickly from 3 different dropdownlists, the second two get erased because it took so long for the first one to load. That ends up being a pain.Is this normal? Why do they take so long to load? Thanks for any help.

  7. I need to populate a dropdownlist with a set of numbers that are looped (0 - 10). The code I have below works as a static option:Dim numbers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}...but I'd like to have a loop working something like thisDim n As Integer = 0For n = 0 To 10Response.Write(n)Next nDoes anyone know how to do this? Thanks.

  8. Opening a connection is what you do to test it. You could open a different connection, like a socket connection, and see if it connects to the hostname. But the ADODB connection provider does some things automatically (like figures out which port to use, etc), so you would need to add that in yourself to the socket code if you want to go that route.Another solution would be to detect when the error happens and deal with it instead of letting it be a fatal error. Look into exception handling for how to handle errors when they happen.
    Thanks justsomeguy,I received a similar response somewhere else with this example:...objConn = Server.CreateObject("ADODB.Connection")objConn.ConnectionTimeout = 10 On Error Resume Next objConn.Open (strConn)On Error GoTo 0If objConn.State <> 1 Then ... unable to connect to that db ... ... so you get to figure out how to handle that ... ... note that objConn is now useless, so don't attempt to use it ... Else ... should be okay End If...I've added that code without any problems, so we'll see if it works on the next error. Thanks.

  9. We have an application that pulls data from several servers, and one of the external servers that we don't have control of went down recently. When our code attempted to open the connection string to that server, it pulled our entire application down.So I need to know how to check that a connection is working first *before* attempting to open it, so that it won't bring everything else down with it. here is what the connection string looks like:

    Dim strConn As StringstrConn = "Provider=SQLOLEDB; Data Source=SERVERNAME; Initial Catalog=DATABASENAME; User ID=USERID; Password=PASSWORD"

    And here is the line of code that had the error:

    objConn = Server.CreateObject("ADODB.Connection")		objConn.Open (strConn) '<<<----- ERROR OCCURRED HERE!!!

    And and all help is appreciated.

  10. I have an ASP.NET page that parses an external XML feed (please see example code below). It works...but when the feed goes down, it subsequently brings my site down. So I've created a default XML document that's located on my internal server a backup method when/if the external feed goes down. But I have no idea how to do this. If someone could let me know how to accomplish this, or point me in the right direction, that would be great. Thanks in advance.ASP.NET XML FEED CODE

    Dim intSWACounter As Integer = 0		Dim swa_xmld As New XmlDocument() 'Create the XML Document		Dim swa_nodelist As XmlNodeList		Dim swa_node As XmlNode		Dim objShowWeatherAlert As Object = False				'Check for active severe weather alerts		Try			'Load the Xml file			swa_xmld.Load("http://www.weather.gov/alerts-beta/wwaatmget.php?x=COC035") 'LIVE: Example feed		Catch			'What to do when it encounters an error			swa_xmld.Load(MapPath("/mysite/docs/xml/weatheralert_down.xml")) 'DOWN		Finally			'Include code to run, no matter whether the code throws an exception or whether it runs successfully			'Get the list of name nodes			Dim xnm As New XmlNamespaceManager(swa_xmld.NameTable)			xnm.AddNamespace("atom", "http://www.w3.org/2005/Atom")			swa_nodelist = swa_xmld.SelectNodes("/rss/channel/item[title != 'There are no active watches, warnings or advisories in Colorado (Douglas/COC035)']", xnm) 'LIVE		End Try

  11. I received this response from somewhere else:The LoginView only displays content for the *first* matched RoleGroup, not for all matching groups:http://msdn.microsoft.com/en-us/library/sy...rolegroups.aspxWhat a bummer, huh? So I'm now thinking of dynamically handling the links on the code-behind (show/hide) depending on their roles using the User.IsInRole method, kinda like this:If User.IsInRole("Group1") Then hlGroup1.Visible = TrueElseIf If User.IsInRole("Group2") Then hlGroup2.Visible = TrueEnd IfThanks anyway!

  12. I have a very simple page that displays a link for each rolegroup that a member belongs to with ASP.NET membership, lets say Group1 and Group2. For some reason, I can only see the first of two links in a list, regardless of which group it is.I've already verified that both groups are pulling in fine by moving the Group2 link above Group1 to see if it could be viewed: which it was!If Group1 is listed above Group 2, I see the link to Group1. But if I move the link for Group2 above Group1, I see the Group 2 link. I don't have a bunch of snazzy-dazzy complicated code on this page, so I'm stumped. Why could this be happening? I'd appreciate any help. Here is my code:groups.aspx.vb

    Partial Class groups	Inherits System.Web.UI.Page	'Pull username	Dim strLoginUserID As String = Context.User.Identity.NameEnd Class


    <%@ Page Language="VB" title="List of Groups" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" EnableSessionState="true" EnableViewState="false" CodeFile="groups.aspx.vb" Inherits="groups" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">	<asp:LoginView ID="LoginView1" runat="server">		<RoleGroups>			<asp:RoleGroup Roles="Group1">				<ContentTemplate>					You are a member of group 1: <asp:HyperLink ID="hlGroup1" NavigateUrl="group1.aspx" runat="server">Group1</asp:HyperLink>				</ContentTemplate>			</asp:RoleGroup>			<asp:RoleGroup Roles="Group2">				<ContentTemplate>					You are a member of group 2: <asp:HyperLink ID="hlGroup2" NavigateUrl="group2.aspx" runat="server">Group2</asp:HyperLink>				</ContentTemplate>			</asp:RoleGroup>		</RoleGroups>	</asp:LoginView></asp:Content>

  13. I need to know if you can nest a datalist within a LoginView's RoleGroup. I have two separate datalists, and I want to show one for admin users, and another for dept-specific users using ASP.NET Membership. Here is what I have:

    <asp:LoginView ID="LoginView1" runat="server">		<LoggedInTemplate>			Below is a list of jobs:		</LoggedInTemplate>		<RoleGroups>			<asp:RoleGroup Roles="Public Works">				<ContentTemplate>					<!-- DEPT-SPECIFIC DATALIST GOES HERE -->			<asp:DataList ID="dlJobs_depts" runat="server">				<ItemTemplate><asp:Label ID="lblJobTitle" runat="server" /></ItemTemplate>			</asp:DataList>				</ContentTemplate>			</asp:RoleGroup>			<asp:RoleGroup Roles="Power Admin">				<ContentTemplate>					<!-- ADMIN DATALIST GOES HERE -->			<asp:DataList ID="dlJobs_admin" runat="server">				<ItemTemplate><asp:Label ID="lblJobTitle" runat="server" /></ItemTemplate>			</asp:DataList>				</ContentTemplate>			</asp:RoleGroup>		</RoleGroups>	</asp:LoginView>

    And this is the resulting error: Compiler Error Message: BC30451: Name 'dlJobs_admin' is not declared.So my questions are: * Is there a way to do this? * If not, what would be an alternative? * If so, what am I doing wrong?Thanks for any and all help.

  14. Here are more details:I've tested all of the stored procedures on the web page and within SQL Server's Management Studio, and they work great. And as I stated, the data is appearing in the source code. Thanks.ASP.NET PAGE:

       <form id="formEmployees" name="formEmployees" enctype="multipart/form-data" runat="server">		<div id="viewstatecontent">		<table width="100%" id="Employees">			<tbody>			<asp:DataList ID="dlEmployees" runat="server" OnItemDataBound="dtlEmployees_ItemDataBound" RepeatLayout="Flow">				<HeaderTemplate>					<tr>						<td>Full Name</td>					</tr>				</HeaderTemplate>				<ItemTemplate>					<tr>						<td>							<asp:Label ID="lblFullName" runat="server"></asp:Label>						</td>					</tr>				</ItemTemplate>			</asp:DataList>			</tbody>		</table>		</div>	</form></asp:Content>


    Partial Class employees	Inherits System.Web.UI.Page	'Assign global variables	Dim sqlConn As SqlConnection	Dim sqlCmd As SqlCommand	Dim strConnection As String	Public strJobID As String = Nothing	Private ds_details As New DataSet()	Private cmd_details As SqlDataAdapter = New SqlDataAdapter	Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)		'Assign connection string		strConnection = System.Configuration.ConfigurationManager.AppSettings("strConn_Employees")		sqlConn = New SqlConnection(strConnection)		strJobID = Request.QueryString("JobID")		'Bind data		BindstrDbRecordID_employeedetails()	End Sub	'Bind Data to DataList Populating the Dataset	Sub BindstrDbRecordID_employeedetails()		'SELECT applications from database		cmd_details = New SqlDataAdapter("spEmployees @jobid = '" & strJobID & "'", sqlConn) 'LIVE		'Bind data		cmd_details.Fill(ds_details, "tblEmployees")		dlEmployees.DataSource = ds_details		dlEmployees.DataBind()	End Sub	'The ItemDataBound Event	Public Sub dtlEmployees_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs)		Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)		If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then			'Assign database values			Dim strDbFName As String = drv.Row("FName").ToString.Trim			Dim strDbMName As String = drv.Row("MName").ToString.Trim			Dim strDbLName As String = drv.Row("LName").ToString.Trim			'Assign label value			CType(e.Item.FindControl("lblFullName"), Label).Text = strDbLName & ", " & strDbMName & " " & strDbFName		End If		drv = Nothing 'Close DataRowView	End SubEnd Class

  15. Ok, I solved it using a different method, and I thought I'd post it in-case it would help anyone else. I changed my approach because when I added a runat="server" attribute to the div tag so that I could work with ASP.NET controls, the JavaScript wouldn't run. So there really wasn't a way for me to work with client-side and server-side tags together.So I put the entire div section into an ASP.NET UpdatePanel, and then added more script to add "DISPLAY:none" to the style attribute onLoad of the body tag. Doing this means that the div section stays open when AutoPostBack's occur, but also toggles as I wanted it to.Here's my code:Additional JavaScript Code:

    function resetToggle() {	var strContactInfoToggleDiv = document.getElementById('Section_open');	strContactInfoToggleDiv.style.display = 'none';}

    MasterPage.master's body tag:<body onload="resetToggle()">ASP.NET Code:

    <asp:UpdatePanel ID="ContactUpdatePanel" UpdateMode="Always" ChildrenAsTriggers="true" runat="server">					<ContentTemplate>						<asp:Panel ID="ContactPanel" runat="server"><div id="Section_open" name="Section_open">				<table align="center" id="ContactInfo">						<tr>							<td colspan="2" align="center">								<a href="java script:swaptabs('Section_closed','Section_open');">									[-] Collapse Section								</a>							</td>						</tr>						<tr>							<td align="right" width="20%">								Full Name							</td>							<td width="80%">								<asp:Textbox ID="txtFullName" columns="20" MaxLength="50" runat="server" />						</td>						</tr>				</table>				</div>						</asp:Panel>					</ContentTemplate>				</asp:UpdatePanel>

    NOTE: I replaced the dashes with underscores (Section-open = Section_open) in order to be valid.Thanks for your included code; I didn't see it until after I was done with my solution. I'll add it to my library if I ever need it. I appreciate your help!

  16. I have a pretty nifty JavaScript toggle that I found on some site, and customized for use on my ASP.NET (VB.NET) site. It works great, except for one thing: when a user causes a client-side postback because AutoPostBack is set to true on the ASP.NET page's web control, the current toggled state goes away, and that toggle pane is closed (DIPLAY:NONE;).I need for the toggled window to maintain whatever state it's in when a user causes a client-side postback on the form. Does anyone know how to do this? I'd appreciate any help. Here is my code:JavaScript Code//Source: http://blog.movalog.com/a/javascript-toggle-visibility/, scroll down to Neeraj Mauryafunction swaptabs (showthis,hidethis) {//begin function var style2 = document.getElementById(showthis).style; style2.display = "block"; var style3 = document.getElementById(hidethis).style; style3.display = "none";}//end functionASP.NET Code: (only section referenced)

    <form id="formContactInfo" name="formContactInfo" enctype="multipart/form-data" runat="server">		<table align="center" id="ContactInfoToggle">				<tr>						<td colspan="2" align="center">Contact Info</td>					</tr>					<tr>								<td colspan="2" align="center">							<div id="Section-closed" name="Section-closed" style="DISPLAY: block">								<a href="java script:swaptabs('Section-open','Section-closed');">									[+]<strong> Add Section</strong>								</a>							</div>						</td>					</tr>				</table>				<div id="Section-open" name="Section-open" style="DISPLAY: none">				<table align="center" id="ContactInfo">						<tr>							<td colspan="2" align="center">								<a href="java script:swaptabs('Section-closed','Section-open');">									[-] Collapse Section								</a>							</td>						</tr>						<tr>							<td align="right" width="20%">								Full Name							</td>							<td width="80%">								<asp:Textbox ID="txtFullName" columns="20" MaxLength="50" runat="server" />						</td>						</tr>				</table>				</div></form>

  • Create New...