Thursday, December 18, 2008

Dual desktop backgrounds

Dual background images of Christina Stürmer tiled onto dual monitors.
I'm probably the last one to figure this one out. I have a picture of Christina Stürmer as my desktop background. I have dual monitors; so naturally, it shows the same on both monitors.
Originally, I went into Display Properties, Desktop, Customize Desktop, Web, and added a new image. I would put the new image on the second monitor, expand it to fit the screen, and then lock the Web items on Desktop. This works fine in most cases. If you were to remote desktop connect, though, it moves your web items around because of the dual-monitor setup.
It occured to me, why not go into Gimp and paste the two images together. Since each monitor is 1600x1200, I opened one image and opened the second as a layer. I moved the second to fit to the right of the first, making sure both were scaled to 1600 x 1200. I saved the image and flattened the layers to 3200 x 1200.
Go to Display Properties, Desktop, select the dual image, and set it to Tile.

Friday, September 19, 2008

More tips on Autorun.inf

More information on Autorun.inf to customize your USB flash drive:

http://autorun.moonvalley.com/autoruninf.htm

USB removable to fixed HD in XP tip

Looking for Autorun and USB flash drive options have yielded some spetacular info.
To trick XP into seeing your USB flash drive as a fixed HD, I found to the folowing to work perfectly:

http://www.lancelhoff.com/2008/06/19/make-windows-see-any-usb-flash-drive-as-local-disk/

I can now use the disk manager to partition the drive into multiple drives.

Thursday, September 18, 2008

AutoRun USB flash drive

Here is a cool tip on how to get a program to run when you insert a USB flash drive:

http://blog.shankarganesh.com/2007/08/11/how-to-autorun-programs-from-usb-flash-drive/

It does not completely autostart for me, but it brings up the AutoPlay window with the first option being the program. Good enough for me.

Blog Policy

I had an epiphany. While googling and researching a tried and true method of installing cygwin on my XP, I found what I thought was step by step information on how to perform such procedure. The format in which the information was displayed, at best, hack-kneed, but it had what I wanted. (I hate tried to read and decipher poorly built web pages with text and links all over the page.)
I followed the procedure and did not succeed in getting the ssh service to start. I tried a few suggested remedies as prescribe by the same page to no avail. I google the message I was getting about the ssh service not starting and found out that indeed I had installed cygwin incorrectly.
My enlightened thought is this:

Rather than I post solutions to the questions and problems I incur, I will post the links to where I found those answers, if they are not mine. This will ensure that if you follow the right instructions. My intention is that I not give you wrong answer, but the proper one.

Friday, August 8, 2008

Redirect a page

>meta http-equiv="REFRESH" content="25; url=Default.aspx<


This html line will redirect your page to the url listed for the number of seconds shown. In this case, 25 seconds. The page is redirected to Default.aspx. Customize as you see fit.

Friday, July 25, 2008

AJAX Toolkit revealed!

With this Cost Recovery project in full swing, I am at the phase of retooling the application. The D&I group is on its way to completing the CSP application which facilitates the tracking of contaminated sites. Focus is shifting over to this Cost Recovery and as a result, meetings have be conducted to look at a new approach to this project; the idea is to optimally develop an intuitive interface and process to the application.

I started a new VS 2008 project, but the others have VS 2005. They can not open my project. We use SourceSafe to check in and out pages of the projects on which we work. This keeps us from overwriting each other's work.

In the effort to make my project compatible with VS 2005, I started the project using .NET 2.0 rather than 3.5. Little did I know that this kept the AJAX Extensions and Toolkit unavailable in my project. I had previously installed the kit compatible with 3.5.

So at this point, I created another project using the 3.5 Framework and am transferring all my work over to it. It was rather frustrating trying to figure out why I did not have the toolkit. I tried re-installing it.

All along it was the fact the project was using .Net Framework 2.0. No doughnut for me.

Tuesday, July 1, 2008

Modals in Gridviews

Setting up a pop-up modal is not as hard as I had thought. I am using the Selector tool as before, it is a GridView with the Autoselect enabled. I add the ModalPopupExtender from the toolkit. I add an <asp:Button ID="dummybutton" runat="server" style="dislay: none" /> and set TargetID="dummybutton". The button is hidden and will not be used. In the code behind the page, use the ID for the ModalPopupExtender to show the modal. Here is an example:

protected void ux_ResultList_SelectedIndexChanged(object sender, EventArgs e)
{
//a row has been selected, save the hazard id as a session varaible HttpContext.Current.Session[DataKey] = ux_ResultList.SelectedDataKey.Value;
// show the modal using the extender
ux_ResultList_ModalPopupExtender.Show();
}

ux_ResultList is the GridView, ux_ResultList_SelectedIndexChanged() is the procedure called when the GridView is selected, and ux_ResultList_ModalPopupExtender is the ModalPopupExtender. Don't confuse the Panel with the ModalPopupExtender. The extender shows the Panel, you tell the extender to show.
Next, I will show you how to populate the modal with the selected site information.

Using Modals to Edit

I am getting to the point where I am ready to show my web application to the Cost Recovery section. I have a section where the billing is handled and then a section for reports. In each, I have editing capabilities for each entry or site. This is fine and practical once all the Cost Recovery data is imported and polished from the Excel workbooks used to track these sites. However, I added an "Edit" section which still allows editing of these sites. Why the redunancy? I don't intend to duplicate what is all ready handled in the other sections.
My intention is to handle the editing differently. In the first two, editing is done on a selected site or entry by bringing up a page with that information. The user will have to go back to the list and select another using the menus. Fine for few edits.
Once this web application is in production, at least initially, there will be a lot of editing to fit the data into the application and match it with the other databases.
My Edit section will allow the user to select each site and pop up the modal with its information to be edited. It is saved and the modal closed leaving the site selector intact and unchanged. The user selects the next site and repeats the process.
Using a Ajax modal is pretty straight forward. Using the Ajax Toolkit, set the TargetID as the control to activate the modal and PopUpID as a Panel to display and atleast a CancelControlID for the control to close the modal.
The issue at hand is the TargetID is actually not a control such as a Button or LinkButton, but the Select in a GridView. You add the PopUpModal to the GridView, but just clicking on the GridView pops up the modal. This prevents the user from selecting an entry in the GridView and as a result no specific site information can be passed on to the edit modal. I will demostrate how to solve this in the next post.

Friday, June 6, 2008

Comparing Tables in a Selector

Well, I do apologize for the lapse. I get so involved that I overlooked this.
I have come up with a solution to compare two tables when displaying one in the selector.
I defined a procedure just like the ShowUserButton to compare tables:
    public bool CompareTables
{
set
{
HttpContext.Current.Session[UniqueName + "CompareTables"] = value;
if (value)
{
ux_UserResults.Visible = true;
FillResultsByCompareTables(); //add the results that belong to the user to the gridview
}

}
get
{
if (HttpContext.Current.Session[UniqueName + "CompareTables"] == null)
HttpContext.Current.Session[UniqueName + "CompareTables"] = false; //default to false
return (bool)HttpContext.Current.Session[UniqueName + "CompareTables"];
}
}

When true, it calls the procedure FillResultsByCompareTables(). Just like ShowUserButton, I call this by setting CompareTables to true:
MainSelector.CompareTables = true;          // I made this to compare two tables and display the results in the selector - Briscoe 05.27.08

Tuesday, May 27, 2008

Selector tool

Antoine has a rather nice selector tool that is used on the main page of his Contaminated Sites database. It defaults to site listed by username. The user can then select sites by beginning letter or by searching the list by keywords.
The problem I have run into using this selector is that I don't want to display my tables by username, which is the default. Some of the tables with which I work do not have a username. To use the selector, the table would have to have a field labeled 'Username'; otherwise, an error would result. Another problem will be listing a selector by comparing values from two tables; which this does not. I will delve into this topic later.
I just found out how he has the selector default to filling the gridview selector with sites based on username. In the code behind the main page, I define the database and the table along with other information about my data to display in the selector:

protected void Page_Load(object sender, EventArgs e)
{
//assign page name to master page
Label pageLabel = (Label)Page.Master.FindControl("ux_PageTitleLabel");
pageLabel.Text = "Main";

//set up the user control
MainSelector.Database = "CostRecovery";
MainSelector.Table = "CRList";
MainSelector.DataKey = "LC";
MainSelector.OrderBy = "CO#";
MainSelector.ResultText = "Sites";

MainSelector.SelectorChanged += MainSelector_SelectorChanged; //register the event from the selector

if (!IsPostBack)
{
           MainSelector.ShowUserButton = false;        // Setting this to true causes the selector to default fill by username

MainSelector.AddResultColumn("SiteDescription", "Site Name");
MainSelector.AddResultColumn("LC", "Ledger Code");
MainSelector.AddResultColumn("CO#", "Contract Number");
MainSelector.AddResultColumn("PjMgr", "Project Manager");
MainSelector.AddResultColumn("CRStatus", "CR Status");

It is the MainSelector.ShowUserButton that sets off the default fill by username. When called and if true, the procedure calls the FillResultsByUserName routine.

public bool ShowUserButton
{
set
{
HttpContext.Current.Session[UniqueName + "ShowUserButton"] = value;
if (value)
{
ux_UserResults.Visible = true;
FillResultsByUserName(); //add the results that belong to the user to the gridview
}
}
get
{
if (HttpContext.Current.Session[UniqueName + "ShowUserButton"] == null)
HttpContext.Current.Session[UniqueName + "ShowUserButton"] = false; //default to false
return (bool)HttpContext.Current.Session[UniqueName + "ShowUserButton"];
}
}


I don't expect anyone without all the code to fully understand what is going on here. I don't completely. But as a reminder to me of what I found today, it will do. I do have a foundation on how this selector works now and will be able to customize it to work with multiple tables hopefully.

Wednesday, May 21, 2008

Recent View table


While trying to set up my database, I wanted to develop a wiki to track my database changes. I chose this blog. However, I came across a website in the process. I has wiki; but more importantly, it has database capabilities. I copied an Excel table and converted it over to a database online. While working with this data, I noticed the site has a Recent View feature which keeps track of records that you have viewed. This is a nice feature that I would like to add to my application. It proved rather difficult overall, but now I have it working. Working the way I want it to as well.
First of all, I set up a web user control for this Recent View. I am using a master page and a web form to designate the content. My content consists of a GridView of the Billing Log records, Main Menu user control, and this control. I will explain this set up in later postings.
In the user control, I set up a DataList with the SqlDataSource is my RecentViewed table. I went into SQL Management Studio and created this table.
My DataList looked something like this:


<asp:DataList ID="RecentViewDataList" runat="server" DataSourceID="RecentViewedSqlDataSource" onselectedchange="RecentViewedDataList_SelectorChanged">
<HeaderTemplate>
<asp:Label ID="RecentViewedHeaderLabel" Text="Site" runat="server"/>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="RecentViewedIDLabel" CommandArgument='<%# Eval("ID") %>' Text='<%# Eval("Site") %>' runat="server" OnClick="RecentViewClick" />
</ItemTemplate>
</asp:DataList>

Below this was my SqlDataSource:


<asp:SqlDataSource ID="RecentlyViewedSqlDataSource" runat="server" connectionstring="<%$ ConnectionStrings:DevConnectionStringCostRecovery %>" selectcommand="SELECT TOP 10 RecentViewed.RecentKeyID as 'ID', BillingLog.Site as 'Site' FROM RecentViewed INNER JOIN BillingLog ON RecentViewed.RecentKeyID = BillingLog.ID ORDER BY RecentViewed.RecentStamp DESC" />


I use SELECT TOP 10 to only show the first 10 records ordered by RecentStamp. RecentStamp is a timestamp field with a default value of GETDATE(). This automatically puts in the time when a record is inserted into the table. I set my RecentKeyID as "ID" as used in the CommandArgument above. Same for Site. The Text in the LinkButton is displayed on the webpage, but the CommandArgument is the value passed to the RecentViewClick code behind the page. This is how I can show the name of the site, but pass the record number when viewing the record.
I also added come color to the backgound item style and alternating style of the DataList, but I won't go into that here. I even put an background image similar to the background image posting.
As far as the code behind, see my next posting...

Friday, May 16, 2008

SQL Server Error

Well, I resolved the error about which I wrote in this previous post.

I installed SQL Server 2005 where I uninstalled SQL Server 2005 Express. In my web application, I defined the database connection string to point to the Cost Recovery database in SQL Server 2005 Express. I moved it over to SQL Server 2005 (different folder).
In the web.config file, I change the following entry:
<add name="DevConnectionStringCostRecovery" connectionString="Data
Source=mySQLServer/SQLExpress;Initial
Catalog=CostRecovery;Integrated Security=True"
providerName="System.Data.SqlClient"/>

Where mYSQLServer is the server name. I removed "SQLExpress" from this statement and saved the file. It worked.

IIS

IIS or Internet Information Services is a web server that can be installed from Windows XP Professional.
  1. In XP Pro, click the Start button.
  2. Select Control Panel.
  3. Select Add or Remove Programs.
  4. Select Add/Remover Window Components.
  5. Check Internet Information Services.
  6. Select OK.

IIS will then be installed.

New VS 8.0 Pro and SQL Server 2005 DVDs in!

First of all, my apologies. Normally, I am writing to document any new information or knowledge that gained while developing this Cost Recovery database application. In this case, I am noting the receipt and installation on Visual Studio 8.0 Professional and SQL Server 2005 Developer edition!
I just installed SQL Server 2005 Developer. I uninstalled the Express version first. I don't know per se if that was the best method, but I did have to install IIS before installing the developer edition. I will note how to install IIS in the next posting.
The one problem I am running into is that all the SQL scripts I wrote under Express are in the Express folder of SQL Server Management Studio where the new version is in a separate folder. That is, all the old scripts are there (whew! At first, I thought it had erased all my scripts.) but in the Express folder, not the now default SQL Management project folder.
The other problem now is my Cost Recovery application now gives errors after compiling:

Server Error in '/CostRecovery' Application.

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)

I will work this out. At the moment, I will install the Visual Studio 8.0 pro... Wish me luck!

Footnote:

I fixed the error. It is in this post.

Friday, May 9, 2008

Excel Linked Server

With my new found knowledge of importing Excel data into SQL tables, I came across the scenario of importing a table with no headers. In my case there are column headers, but a spacer row was added to separate it from the actual data. In addition, there are additional tables below also separated by a spacer row to differentiate categories. It is a matter of formatting the tables for look where the simple tables just don't appeal to the eye.

For your sake and not simplicity, I will detail how to create a linked server here.

To link to an Excel workbook and import with no headers, I created a linked server by the following these steps:
  1. Open Microsoft SQL Server Management Studio Express
  2. Connect to your server which has the database in which you wish to create a table.
  3. In the Object Explorer tab, expand Server Objects.
  4. Right-click Linked Servers.
  5. Select New Linked Server.
  6. Under the General page, type in a name for the Linked Server.
  7. Select Other data source for Server Type.
  8. Select Microsoft Jet 4.0 OLE DB Provider.
  9. For Product Name, type in Excel.
  10. Type in the full path and filename of the Excel workbook to which you are linking in Data Source.
  11. In the Provider String, type Excel 8.0; HDR=NO.
  12. Select OK.

You should now have a linked server to your Excel workbook and it will not import the first row as headers.

In my case, my tables were separated by spacer rows. I opened the worksheet and highlighted each table. I defined names for each and used these names to import each table rather than the worksheet name.

Example:

SELECT * INTO mySQLTable FROM myExcelLinkedServer...myDefineNamedTable

Notice there are no brackets or the $ symbol. Brackets and the $ are used when importing a worksheet, not a named range.

If I had only one table and it started in cell A1, I could use the following:

SELECT * INTO mySQLTable FROM myExcelLinkedServer...[myExcelWorksheet$]

Importing Excel data into SQL Server 2005

I have been at a total loss trying to import Excel data into a SQL database. When I first started this project, my task was to use the existing data in the Cost Recovery database to build and develop a working model. I had absolutely no luck getting the data into tables. The method to which I finally resorted was importing the data into Microsoft Access tables; afterwhich, I used the following SQL statement to create a table and import the data:

SELECT * INTO mySQLTable FROM myLinkedServer...myAccessTableName

This just an example where mySQLTable is the name of the table created in SQL, myLinkedServer is a linked server (I have a posting on how to do this), and myAccessTableName is the name of the table I created in Access. This all works, but is tedious.

What I found out when importing data directly from Excel is closing the Excel spreadsheet when trying to import. Otherwise, I kept getting this error:


-- Msg 7399, Level 16, State 1, Line 22
-- The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
-- Msg 7303, Level 16, State 1, Line 22
-- Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

I googled and re-googled looking for an answer. I tried suggestion after suggestion with no luck. It was when I closed the workbook, did I have success. The workbook can NOT be open while trying to import.
The two following statements work, but the first uses a Linked Server and is simpler for me:


SELECT * INTO mySQLTable FROM myLinkedServer...[myExcelWorksheet$]

Again, mySQLTable is the name of the SQL table I want to create and into which import data, myLinkedServer is the name of the Linked Server accessing the Excel workbook, and myExcelWorksheet is the name of the worksheet in the workbook. Include the brackets [ ] and the $ in the worksheet name.

The second method is as follows:


SELECT * INTO mySQLTable FROM openrowset('Microsoft.Jet.OLEDB.4.0','Excel 8.0;database=myFullFilePath\myExcelWorkbook.xls;HDR=YES','SELECT * FROM [myExcelWorksheet$]')

Names are the same as above. myFullFilePath is the complete and full path of where the workbook is located. myExcelWorkbook.xls is the filename of the workbook itself.

Thursday, May 8, 2008

Background Image in GridView


I found out how Antoine displays this in his GridViews in the CSP database. It is a background image for that GridView. You don't see it if there are records to display, but do if there are none.
I was racking my brain how he was doing this because I found the EmptyDataText property to show when there is no data; he was not using this. In Larry's Report page, I wrote a stored procedure to show "No Records." I don't need this now.

Monday, May 5, 2008

Display HTML code in a Blog

I found a couple of site that allow me to convert HTML tags so that I can display code here. These are as follows:

http://www.felgall.com/htmlt47.htm

or

http://www.plus2net.com/html_tutorial/tags-page.php

Just copy, paste, and convert. Recopy the result and paste into the blog. Preview before publishing to ensure layout is correct.

Customize GridView

Microsoft has an fairly simple example of how to customize the GridView when displaying database entries. I turned off the Autogenerate columns because it automatically appends the same columns on my GridView.

I want to reformat the currency to two decimal places and the dates to date only, not time. I have yet to get to that point. But here is my code:


<asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" EmptyDataText="No Data Available." AutoGenerateColumns="false" PageSize="20">
<Columns>
<asp:BoundField DataField="Bill_Number" HeaderText="Bill Number" />
<asp:BoundField DataField="RP" HeaderText="Responsible Party" />
<asp:BoundField DataField="LC" HeaderText="Ledger Code" />
<asp:BoundField DataField="Amount" HeaderText="Bill Amount" />
<asp:BoundField DataField="DateRcvdDOL" HeaderText="Date Rcvd" />
<asp:BoundField DataField="DatePmtSentDEC" HeaderText="Date Payment Sent to DEC" />
<%--<asp:BoundField DataField="Comments" HeaderText="Comments" />
<asp:BoundField DataField="DateSentRP" HeaderText="Date Sent to RP" />
<asp:BoundField DataField="Check" HeaderText="Check Number" />
<asp:BoundField DataField="AmountPaid" HeaderText="Amount Paid" />
</Columns>
</asp:GridView>

Ajax Hover Menu

I have been using a menu format that is used in the CSP application. My thought is if my application is stand-alone, I want it to have a similar look and feel as the CSP application. If it becomes part of the CSP or another application, this would probably facilitate an easier assemblance into an existing database.

CSP is the web application Antione and Coleen have developed to track contaminated sites here at ADEC. It is a very nice program / database.

One of the problems I have run into placing this menu on the right like CSP, is that some of my gridviews of data run off the page. This puts the menu off screen. My initial thought is to use Ajax to put this menu in a drop down that overlays the grid view. It worked after some tweaking.

First, I added this to the top of the page just under the <%@ Page ... %>:

  • <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

The script manager is needed in the content page:

  • <asp:ScriptManager ID="ScriptManager1" runat="server" />

Add the HoverMenuExtender afterwards:

  • <cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="MainMenuButton" PopupControlID="PopUpMainMenu" PopDelay="5000" />

Where:

  • TargetControlID is the name of the object over which the mouse hovers to pop up the menu.
  • PopupControlID is the name of the menu object which will pop up.
  • PopDelay is the amount of delay the menu stays visible after the mouse loses focus on the menu.

For the pop up menu, I added this to the bottom of the page within the area of my page so that is on top of any content when displayed:

  • <asp:Panel ID="PopUpMainMenu" runat="server">
    <!-- Add the Main Menu buttons -->
    <div style="z-index: 9999;">
    <mm1:MainMenu ID="MMCB" runat="server" />
    </div>
    </asp:Panel>
The defines the menu to display. is the web control I made separately to house the menu. Like the Ajax HoverMenu is registered on the top of the page, so is the control:

  • <%@ Register Src="MainMenu.ascx" TagName="MainMenu" TagPrefix="mm1" %>


Tuesday, April 29, 2008

Setting the Start page in Visual Web Developer

When selecting CTRL-F5 to build and run your web application in Visual Web Developer, it normally starts on the current page that is selected. This if fine if you want to only view that page in the web browser. (You can still view other pages as they are part of the build; one just has to set the browser to any other pages in the site.)

If the site is to startup at one particular page (e.g. the default or main page), select the Solution Explorer pane in Visual Web Developer. If it is not visible, select View on the top menu and select Solution Explorer (CTRL-ALT-L). A list of all the pages will be shown. Right-click on the top where your site name and path is listed. Select properties page and the select Start Options. Select Specific page and enter the page or ... to browse. Select OK.

When the site is rebuilt, it will start on the page that was selected.

AJAX (not the detergent)

While trying to debug the code that I copied over to my application, I tried to eliminate the AJAX toolkit used in the code because I did not have the toolkit in place on the 2008 express version of Visual Studio. I could not do this because it caused more errors than it eliminated.

I found out how to install the toolkit. The code used tabs and I wrote seperate AJAX code on another page to determine how this was done. It was simple, but I did have some problem coding the Acordion feature. It has Acordian and AcordionPane, the latter of which is a pane of the first. But I also had to find out about the properties of both because one has while the latter has . I will go into this later.

Cached Variables

I am learning. Looking for a way to pass Hazard_ID. I found out about cached variables. It seems that if I declare a session variable, I can not retrieve as a cached variable. However, if I set a variable using Cache["somevariable"] = somevalue, I can access it as a session variable.

Don't know why. I will have to further my research to determine the difference.

I have tried copying his routines including his web pages where it displays and fills the site information in lieu of passing the variable to his established page. I get multiple errors and had to address each one. I won't detail it here because there were so many.

To make a long story short, I have abandoned copying the code and pages to circumvent passing the variable. I will have to approach this another way, since my .NET coding is weak.

Monday, April 28, 2008

Session Variables II

I came to a point where I was getting his page, but it would not have the correct site information. This meant that the session variable Hazard_ID was not being passed.
I tried adding it to the end of the URL as in http://jn-svrdev1-vma6:81/spar/csp/EditSite.aspx?Hazard_ID=number. This did not work.

Today, I set the DataKeyNames="HazardID" in the asp section of GridView (found on the page that has HTML) instead of on PageLoad() in the code section (found in the C# code behind the aspx page.

I used the following in the OnSelectedChanged and erased last week's coding:
  • int index = GridView1.SelectedIndex;
  • // Display the primary key value of the selected row.
  • txtHazard_ID.Text = GridView1.DataKeys[index].Value.ToString();
I put the correct Hazard_ID in the textbox and selecting Submit button now gives me an error concerning an "ActiveButton" session variable on the EditSites page.

Session Variables

I have a grasp, somewhat, of what session variables are. They are variables defined and exist during the session while an application is running or in this case internet connection to a web site. This allows values to be passed from page to page.

The problem I was investigating was how Antoine was using Hazard_ID as a session variable. The contaminated site information would be displayed when the user selected a site from a list. A new page would be displayed based on this selection. I knew he used the Hazard_ID to find which data to fill the page, but I did not know how he accomplished this.

I was trying to use the following to do so:

GridViewRow row = GridView1.SelectedRow;
txtHazard_ID.Text = Convert.ToString(row.Cells[1].Text);
Hazard_ID = Convert.ToInt32(txtHazard_ID.Text);

GridView1 is the ID of my gridview which displays the table of my data. SelectRow returns which row was selected. row now points to the selected row of GridView1. I then convert to string the values of the second column of the selected row of data. I set Hazard_ID to this value and see if this works with his EditSite.aspx page. Hazard_ID is the session variable used to determine which site to display.

It did not work. I would get errors like "Index was out of range. Must be non-negative and less than the size of the collection." and others. I apologize for not posting on Friday. This would have documented the problems in more detail.

I then studied Antoine's EditSite.aspx code as well as his Selector.ascx page which selects the site. I borrowed more code to pass this Hazard_ID with no luck.

Some of the code is as follows:

HttpContext.Current.Session[DataKey] = GridView1.SelectedDataKey.Value;
//trip the event
OnSelectorChanged(sender, e);
txtHazard_ID.Text = Convert.ToString(GridView1.SelectedDataKey.Value);

I had to define OnSelectorChanged, DataeKey get and set, Hazard_ID set and get. In the Page_Load section I tried to set the DataKeyNames to HazardID, which is the name of my key.

It did not work.

I left Friday unsuccessful.

Thursday, April 24, 2008

CSP Research

Researching the CSP application Antione is developing for information on how I can pass the Hazard_ID to be included with my database. I wish to use it to access the CSP database to lookup site specific information. I was looking in the EditSite.aspx stuff, but to no avail.

Thought a session variable named Hazard_ID would do the trick. Nope.
Then tried passing the variable in the EditSite.aspx?Hazard_ID=1294 url type. Nope.

Looked at Default.aspx, LocationAddress.aspx, and now Selector.aspx (This is the gridview where it lists the sites listed by A, B, C, etc or by search string). It contains the Select link button to direct the page to the EditSite.aspx by site selected. This should help.

I'll post the results later. Time to go home.

CRITTS Meeting

Very informative meeting concerning a time invoicing database application that is being developed. It is not yet ready for production, but looks like I will need to know more about it; it will relate to my database in that it tracks billing and invoicing time worked on specific projects. My database will probably need to access this information in the future. However, CRITTS will not be applied to this section until after 2009. Some major changes in the way site are tracked and billed will result. This is to be determined.

Modified GetLarrysReport Stored Procedure

I modified GetLarrysReport stored procedure to reference my Category table using CategoryID and added HazardID which was included into LarrysReport table. Category field is still in Larry's report. I will drop this column later. I want to be sure CategoryIDs match Category.

I added the column HazardID; it comes from Antoine's CSPV2 database concerning Contaminated Sites database. I will be linking to this database for all site specific data. I updated the HazardID to match his based on matching SiteDescriptions. It worked for some 270 records, I think. There are over 1700 records in my database which is still imcomplete, but it a working model.

When I get a better database going, I will incorporate all data in this program. It will still have to be edited, verified for accuracy, and some manually entered.

An example of a google result that dealt with my linked server error.

I googled my linked server error when I could not get the SELECT statement to work using jn-svrdev1-vma\sql2005. The error was similar to this:

  • The OLE DB provider "SQLNCLI" for linked server reported an error. Authentication failed.

I did find a useful(?) SELECT statement that might at some point help me understand the status of linked servers; but, at this point I can't interpret it. It is as follows:

  • select S.server_id, S.name, S.provider,S.data_source,S.provider_string, L.uses_self_credential
    from sys.servers as S, sys.linked_logins as L
    where S.server_id=L.server_id and S.name=N'TypeServerNameHere'

Of course, I hope you understand 'TypeServerNameHere' is actually replaced by your server name you are trying to access.

What did help me in this google result, was the last post where the guy having the problem resolved the issue by using the option "Login using this security context".

He did not state where he did this. I found in the SQL Managment Studio in my database Server Objects under Linked Server properties for the server I'm trying to link.

Here is the link to the forum posts that discuss his issue: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=990327&SiteID=1

Linking Servers in SQL Management Studio

I forgot to mention that I am working with Microsoft SQL Server Management Studio to link the two databases. I don't want to do like most and leave out critical information by assuming everyone knows the extraneous details when describing the method of working with SQL databases.

To link to SQL Server (in my case, jn-svrdev1-vma7\sql2005), I did the following:

  1. I expanded the Server Objects tab located in the Object Explorer of my database.
  2. I then right-click Linked Servers and select New Linked Server.
  3. Under Select a page, select General.
  4. I select SQL Server
  5. Type in jn-svrdev1-vma7\sql2005 in the Linked server textbox.
  6. Under Select a page, select Security.
  7. Select Be made using the login's current security context
  8. Select Add button
  9. Under Local login, select your user login id
  10. Select OK

You should now be linked to this database.

Linking my database to another database using a linked server

I have had trouble linking to a seperate server called 'jn-svrdev1-vma7/sql2005'. Googling how to lookup a table on another server will tell you just use a simple statement like the following:

SELECT md.*, od.*
FROM myDataTable md
INNER JOIN [OtherServerName].OtherDatabaseName.dbo.OtherDataTable od
ON od.SameFieldID = md.SameFieldID

Simple enough? No, they don't explain that the 'OtherServerName' must be a linked server defined in the 'Server Objects' of your database. I will outline how to link this server in the next posting. I ran into errors trying to do this. Once you have a linked server, you can use a statement like the one above.

I have found that using the Design Query helps in this case, since saves a few keystrokes writing the statement.

Friday, March 7, 2008

Database Notes

I will be using this to keep track on things I do and specificall learn about database programming.

I have learned quite a bit prior to starting this; by that I don't mean I can expertly program one. I am referring to learning SQL and Visual Studio concepts. I have so much to learn.

I wish I had a real working knowledge now. There is so much I want to do, but don't yet know how. Sometimes finding the information on the web can be so elusive and mostly cryptic when I do find topic discussions. It can be so frustrating when others assume.