BrianRudloff.com

.Net Development


My Resume
WebDOCPDF
RTFODTTXT
powered by emurse

Recent comments





Problem with Button on Panel (using PopupControlExtender) not Firing Event

I recently ran into an issue where I was trying to dynamically create a Panel with Buttons, Labels, ect and have it popup using the AJAX PopupControlExtender.  The problem was that whenever you would click on the Button, it wouldn't fire the click event.  The event was there, it just wouldn't execute.  Anyway, to make a long story short.. I had to change the Button's UseSubmitBehaviour to false to get it working.

i.e ( Button1.UseSubmitBehavior = false);

Hopefully, someone will find this post and save themselves some time.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: .net | c# | ajax
Posted by Brian Rudloff on Thursday, July 03, 2008 9:34 AM
Permalink | Comments (0) | Post RSSRSS comment feed

SQL Server Index Issue - Causes "Order By" Error

I recently came across the following error after using the SQL Server 2005 Index Tuning Wizard:

A column has been specified more than once in the order by list.  Columns in the order by list must be unique.

I assumed the error was caused by a line in one of my stored procedures or triggers and I spun my wheels for quite some time looking for the root cause.  As it turns out,  the tuning wizard added several hypothetical indexes to my table that weren't displaying when I tried to view the indexes the traditional way (right clicking on the table and choosing 'manage indexes'.  To see them, I had to run the following stored procedure:  sp_helpindex ('table') 

After dropping all of the hypothetical indexes,  the issue was resolved.   

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: sql
Posted by Brian Rudloff on Tuesday, January 29, 2008 11:51 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Sharepoint Services 2003 - Workaround for filtering on today's date

SharePoint Services 2003 does not initially come with a column for Today's Date.  However, there is a workaround.  Chris Johnson @ msdn wrote a great article on exactly how this works.  But basically, you can trick SharePoint into using Today in a function and create whatever calculated field you need.

I recently had to use this technique to filter a SharePoint Calendar.  I wanted it to display only upcoming events and out of the box, the calendar displays everything.  Here's what I found:

How to Filter a SharePoint Services 2003 Web Part Calendar to Only Show Upcoming Events

1.  Create a new column with the Column Name: Today (It doesn't matter what the type is, so leave it default)

2. Next, create a column with the Column Name: Begins.  In the formula section, enter: =[Start Time].  The data type should be: Date and Time.  The Date and Time format should be: Date Only.

3. Create a new column with the Column Name: Date_Range.  (or something).  In the formula section, enter: =Today-Begins.  The data type should be: Number(1, 1.0, 100).  Set the Number of decimal places to: 0.

4. Here's the weird part.  Go back and delete the original Today column created in Step 1.  I know what you're thinking...but trust me...  If you had read the article I mentioned earlier, you'd understand where this is going.

5. Now Create the Calendar Web Part by Clicking on Edit Page > Add a Web Part > Check Calendar > Click Add.

6. Create the customer view by Clicking on the Calendar Hyperlink > Settings > Create View.  Under "Start From an Existing View", Click Calendar.  Give the Calendar View a Name and then scroll to the bottom of the page and Select "Show items only when the following is true:"  In the first Dropdown box, Select: Date_Range.  In the second Dropdown box, Select "is less than".  Finally, enter a zero (0) into the textbox.

That's it!  When you view your page, you should now have a Calendar Web Part that displays only upcoming events.  If by any chance it’s still showing all events, you may have to play with the view setting for the calendar.

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Sharepoint
Posted by Brian Rudloff on Thursday, August 30, 2007 8:49 AM
Permalink | Comments (2) | Post RSSRSS comment feed

Exporting SQL Data to Excel Programatically (Without DTS)

The following code can be used for creating a spreadsheet on the fly and presenting it to a user for download.  It's important to note that it doesn't really create a spreadsheet on the fly... rather it copies a template sheet and then populates the copy.  Either way, to the user its transparent.  Just create a template sheet with all of your column names and store it in one of your project folders.

The code is as follows:

protected void btn_exportdata_Click(object sender, EventArgs e)

     {               
         //Creates a guid named filequid (unique identifier)
        Guid fileguid = Guid.NewGuid();
        //String the new filename  * Replace “Server_Name” & “Folder_Name”     
        string filename = @"\\Server_Name\Folder_Name\" + fileguid.ToString() + ".csv";
        
        //Create the new file and copy the template column names into it * Replace “Server_Name” & “Folder_Name”
       File.Copy(@"\\Server_Name\Folder_Name\Template.xls", filename);              
      
       //Make your database connection
        string cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        SqlConnection dbConnection = new SqlConnection(cs);
        dbConnection.Open();
       
       //Create sql command
        SqlCommand export_data = dbConnection.CreateCommand();
       
       //Populate sql command * Replace “Select * from customers” with your select command
       export_data.CommandText = @"insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=" +     filename + ";', 'SELECT * FROM [Sheet1$]') select * from customers";
                    
        //Execute sql command
         export_data.ExecuteNonQuery();
       
        //Close the connection
         dbConnection.Close();
       
      //Present the spreadsheet to the user for download * Replace “sitename.com/Folder_Name” with your specifics
        Response.Redirect("http://sitename.com/Folder_Name/" + fileguid.ToString() + ".csv");
    }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,
Categories: .net | c# | sql | excel
Posted by Brian Rudloff on Thursday, August 30, 2007 8:45 AM
Permalink | Comments (0) | Post RSSRSS comment feed