Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender

kwilliams's Achievements


Member (2/7)



  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.
  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.
  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 ASP.NET PAGE: <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. No replies yet? Too bad. I did find this article on 4guysfromrolla with using a DataGrid for the same thing: http://www.4guysfromrolla.com/articles/112603-1.aspx, but I don't like the limitations that the DataGrid gives me. If W3Schools doesn't intend on updating that page with another newer language, that's fine. I'd just like to know. It's been there for awhile now.
  6. I've always loved this simple code setup that allows you to edit an XML document with XSLT and ASP code: http://www.w3schools.com/xsl/xsl_editxml.asp But I've always wondered whether or not they'll add to that page with matching ASP.NET/VB.NET code. Is that something that W3Schools looks to do in the near future?
  7. 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")
  8. 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.
  9. Here's the solution:Dim n As IntegerFor n = 0 To 10 Dim listItem As New ListItem listItem.Text = n DropDownList1.Items.Add(listItem)NextThanks anyway:)
  10. 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.
  11. 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.
  12. 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.
  13. That's obviously a typo. Sorry about that, and thanks again for the help.
  • Create New...