Search this insane blog:

Thursday, December 18, 2008

Excel: Find last row in a spreadsheet

Sub xlCellTypeLastCell_Example_Row()
Dim LastRow As Long
With ActiveSheet
LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
End With
MsgBox LastRow
End Sub

The Pygmalion Effect

The Pygmalion Effect

aka:Self Fulfilling Prophecy , The Rosenthal Effect

Praise with vision goes a long way.

People tend to live up to what's expected of them and they tend to do better
when treated as if they are capable of success.

These are the lessons of The Pygmalion Effect.

Pygmalion first appeared in Greek mythology as a king of
Cyprus who carved and then fell in love with a statue of a woman, which
Aphrodite brought to life as Galatea.

Much later, George Barnard Shaw wrote a play, entitiled Pygmalion, about Henry Higgins (the gentleman) and Lisa Doolittle (the cockney flower girl whom Henry turns bets he can turn into a lady).



So the Pygmalion Effect has come to mean "you get what you expect." If you expect disaster, your expectations may well be met in a kind of "self-fulfilling prophecy," yet another catch phrase about the pressure of expectations.




from :
http://www.envisionsoftware.com/articles/Pygmalion_Effect.html

Wednesday, December 17, 2008

Big Oven Recipe software

The only user-data files that BigOven uses are the ones in the "My BigOven Recipes" folder. The application itself installs to c:Program FilesLakefront SoftwareBigOven.

---
Make a copy of the recipe and shopping list data. Locate your "My BigOven Recipes" folder, and check the "last modified" dates to make sure you've got the most recent ones. You can search for the files named "*.crb" to locate them easily. Usually, they are either under your "My Documents" folder or your "Shared Documents" folder. If you've updated multiple times, you may have a couple copies -- you can check the "last modified" date in Windows Explorer to make sure you have the most recent set.


Make a copy of the recipe and shopping list data. Locate your "My BigOven Recipes" folder, and check the "last modified" dates to make sure you've got the most recent ones. You can search for the files named "*.crb" to locate them easily. Usually, they are either under your "My Documents" folder or your "Shared Documents" folder. If you've updated multiple times, you may have a couple copies -- you can check the "last modified" date in Windows Explorer to make sure you have the most recent set.

for detailed instructions, you can go to http://www.bigoven.com/cs/forums/t/1665.aspx

Monday, December 15, 2008

confirm pop up in javascript

if (confirm('Are you sure?')==false) return false;

hit the easy button!!

Monday, December 8, 2008

SSRS: What Reports do you have out there?

list all the reports you have on your server:

use ReportServer


select ds.name as datasourcename ,
ct.name as itemname ,
ct.path
from dbo.catalog ct (with nolock)
inner join dbo.datasource ds
on ct.itemid = ds.itemid
where type = 2
order by datasourcename ,
itemname

Saturday, August 16, 2008

Re Sharper Add-In Review

I am new to C#.

in fact, I'd call myself very new!

ReSharper add-in for visual Studio is absolutely wonderful. It has shaved off many hours of pulling hair and getting a flat forehead.

please google it, try it.. for middle of the road novice/beginners this is fantastic!

Connect to a stored procedure and playing with an array

have on hand: a label called lblVerse
a stored procedure letting you have the proper permissions to reach.

  1. web.config called db3

  2. Table called "verses"

  3. a column called "verse"

  4. a stored procedure called "rndVerse"
----- STORED PROCEDURE (SCRIPT)----

create procedure [dbo].[rndVerse]
as
select verse
into [#t]
from
(select verses.verse
from verses
inner join (select top (1)
newid() as Expr1, id
from verses as verses_1
order by Expr1
) as dt
on verses.id = dt.id) as dt ;
select verse from #t ;
drop table #t ;

GO


-----code behind:-------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)

{

string MyTable =
"verses";

string MySingleColumn = "verse";
string MyWebConfigString = "db3";string MyStoredProcedure = "rndVerse";

string connString =
ConfigurationManager.ConnectionStrings[MyWebConfigString].ConnectionString.ToString();

SqlConnection conn =
new SqlConnection(connString);


conn.Open();

SqlCommand command =
new SqlCommand(MyStoredProcedure, conn);


SqlDataAdapter adapter = new SqlDataAdapter(command);


DataSet ds = new DataSet();

adapter.Fill(ds, MyTable);

if (ds.Tables[MyTable].Rows.Count < 1)


{

Response.Write("I am sorry, there are no reports to be shown");

}

int theseRowsCounted = ds.Tables[MyTable].Rows.Count - 1;
// array length (rank of1 [column], of course...)


string thisColumnHeader = ds.Tables[MyTable].Columns[0].ToString();//grab header names:

string thisColumnValues = ds.Tables[MyTable].Rows[theseRowsCounted].ItemArray[ds.Tables[MyTable].Columns.IndexOf(MySingleColumn)].ToString();// that grab the values:

ArrayList theseRows = new ArrayList();
// please notice: there is only one row rendered:

theseRows.Add(thisColumnValues);


foreach (string n in theseRows)
//
kept this way just in case you want to render more rows in fun ways

{


lblVerse.Text = n;

}


}

}

Friday, August 15, 2008

Reporting Services URL strings

If you want to pass settings through the string:


base string:
http://[servername/[report_servername]/"%2f" / receiving / "%2f"/[report name]

all strings are to be rendered:

1. render report (require) "&rs:Command=Render"

- turn off toolbar: "&rc:Toolbar=false"

- turn off parameter viewability: "&rc:Parameters=false"

- implement a string search on report: "&rc:FindString=SPKRI"

- send to a frames page: "LinkTarget=[window_name]" (or you can target a new window using LinkTarget=_blank)

- for each parameter fed into report: &[parameterName]=NumberOrTextWithoutQuote
-example: &receipt_order=RC00000306

- for concatenating parameters &r[parameterNmae]=NumberOrTextWithoutQuote&[parameterName]=NumberOrTextWithoutQuote

HTML Charachter entities

Symbol HTML Number Description
======= ======= ======= ======= =======

&#32; space
! - &#33; - exclamation point
" - &#34; - double quotes
# - &#35; - number sign
$ - &#36; - dollar sign
% - &#37; - percent sign
& - &#38; - ampersand
' - &#39; - single quote
( - &#40; - opening parenthesis
) - &#41; - closing parenthesis
* - &#42; - asterisk
+ - &#43; - plus sign
, - &#44; - comma
- - &#45; - minus sign - hyphen
. - &#46; - period
/ - &#47; - slash

Tuesday, August 12, 2008

asp.net user control

user control research
==========================
adding code to your user control
http://msdn.microsoft.com/en-us/library/hdbz1a66.aspx
(main page): http://msdn.microsoft.com/en-us/library/ttb1w24s.aspx


http://msdn.microsoft.com/en-us/library/ttb1w24s.aspx

do a walkthrough for binding to a user control(yuck, this is for a windows object):
http://msdn.microsoft.com/en-us/library/ms171926.aspx




http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/9286534e-26d2-4d7e-

90b8-a67f22ffb565/

Monday, August 11, 2008

Ultra Edit? or Notepad++

While I enjoyed the simplicity and light-weightness of Notepad +
Notepad ++ is even more delighting.

For the serious "I want to buy" stuff I like ultra edit.
Note tab pro is cheaper though

Thursday, August 7, 2008

Gagets: Time Tracking software

free, works on xp & vista:
http://www.argosoft.com/RootPages/FreeToys/Default.aspx

woks on vista, using xml locally, your data is not traversed over the internet (developer gets money by google ads):

http://screeperzone.com/category/activity-tracker/

Wednesday, August 6, 2008

web.config sundry mumbles

access the SqlConnection from the page (expressed below as a string, but you get the hint):
string connStr = ConfigurationManager.ConnectionStrings["mem"].ConnectionString;

access settings from the web.config:

Color colorBack = Color.FromName(ConfigurationManager.AppSettings["BackColor"]);

T-SQL to .NET page: output data, having it concatenated

declare @MyString output nvarchar(500),
@delimiter char(1),

@string1 char(4), @string2, char(4)
set @delimiter = ','
select @Mystring =
@string1 + @delimiter + @string2

---
Then you can parse out the data using an array/ code behind.

Tuesday, August 5, 2008

ASP with c#: make an object read-only

create an item as read-only



function setReadOnly(obj)
{
obj.readOnly = true
obj.style.color = "white"
obj.style.backgroundColor = "black"
obj.tabIndex = -1
}

if (form1.blaha.value == "blah ")
{
setReadOnly(form1.myobject)
}

Sunday, August 3, 2008

rapidly extract CSV file information into SQL Server



-- in the end,
i will be able to query a file straight from sql server:



-- ** select * from
txt_delimited...book1#csv ** if the
file name is book1.csv i saved a text delimited file in a folder txt_del on my
desktop. you can drag and drop any file into that particular folder and do a
quick-query.



-- note: if you
super-tweaked your database collation, your collation must be case insensitive!



declare


-------------------------------------------------------------------








@nameoflinkedfiletype sysname,

@describemyfile nvarchar(256),
@provider nvarchar(256),
@myfilefolder
nvarchar(4000),

@extrafileinfo
nvarchar(4000),

@sqlserverloginame sysname



-------------------------------------------------------------------------------------



set @nameoflinkedfiletype =
'txt_del'

set @describemyfile
= 'text'


set @provider
= 'microsoft.jet.oledb.4.0'


set @myfilefolder
= 'c:\users\[username]\desktop\txt_del'


set @extrafileinfo
= 'text;hdr=yes;fmt=delimited'


set @sqlserverloginame =
'machine name\login'

exec
master.dbo.sp_addlinkedserver


@server
= @nameoflinkedfiletype,

@srvproduct = @describemyfile,

@provider = @provider,

@datasrc
= @myfilefolder,

@provstr
= @extrafileinfo


-- add a linked server login.... etc..

exec
master.dbo.sp_addlinkedsrvlogin
@rmtsrvname = @nameoflinkedfiletype,
@locallogin = @sqlserverloginame,
@useself = 'true'


-- then from
now on, you can simply type a select on whatever file you have on that folder!!!
likek ..

SELECT verse
INTO poetry
FROM txt_del...Book1#csv AS Book1#csv_1


Wednesday, July 30, 2008

Create a function to convert decimal to fraction

http://blogs.techrepublic.com.com/datacenter/?p=348

execute javascript on page

private void SetFocus(Control ctrl)
{
// Define the JavaScript function for the specified control.
string focusScript = "";
// Add the JavaScript code to the page.
Page.RegisterStartupScript("FocusScript", focusScript);

asp.net 2.0 with c#: Accessing connection string using code behind

-- straight away connection
private void Page_Load(object sender, EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open();

// perform work with connection

}
}
--- to encapsulate a connection stored in your web.config
private void Page_Load(object sender, EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open();

// perform work with connection

}
}

----------------------------
private void Page_Load(object sender, EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open();

// perform work with connection

}
}



you can read the details at odetocode...
source: http://www.odetocode.com/Articles/345.aspx

Tuesday, June 24, 2008

Find Indexes on columns

SELECT OBJECT_NAME(sys.sysindexes.id) AS [object name], INDEX_COL(OBJECT_NAME(sys.sysindexes.id), sys.sysindexes.indid, 1) AS [column]



FROM sys.sysindexes
INNER JOIN



sys.sysobjects
ON sys.sysobjects.id = sys.sysindexes.id



WHERE (sys.sysobjects.xtype
IN ('u', 'v')) AND (sys.sysindexes.status
= 0) AND (INDEX_COL(OBJECT_NAME(sys.sysindexes.id), sys.sysindexes.indid, 1) IS NOT NULL)



ORDER BY [object name]

Sunday, June 15, 2008

Membership database permissions.

sp_help 'aspnet_CheckSchemaVersion'
-- if the website has an error lke
-- EXECUTE permission denied on object 'aspnet_CheckSchemaVersion'...
-- look inside your database to decide who gets permissions.

sp_addrolemember 'aspnet_Membership_FullAccess', 'username'


note: if you don't know anything about asp.net memberships and have the SQL server management studio, search for the application on your computer called aspnet_regsql.exe.

That will pop up a wizard and will install the membership database you will neeed for membership on your asp.net website.

background: I stumbled upon this when I installed asp.net's default personal webpage template.

Thursday, April 3, 2008

grabbing a csv from a csv file

I created this code, but haven't tested the values with a schema.ini file yet. My old programming co-worker had this working quite well.

----

I typically use a ssis package with a credential (previous blog) to do this, but my friend does it this way .. well, he is testing it.
He is having trouble initiating with a schema.ini file..




EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE with
override
GO
IF OBJECT_ID('#MyTable') IS NOT NULL
BEGIN
DROP TABLE
#MyTable
END
SELECT *
INTO #MyTable
FROM
OPENDATASOURCE(
'Microsoft.Jet.OLEDB.4.0'
,'Data
Source="C:\Event_Leads\G2WAttendee_02125312";Extended
Properties="text;HDR=No;FMT=Delimited";'
)...[G2WAttendee#csv]
Select *
from #MyTable
DROP TABLE #MyTable
EXEC sp_configure 'Ad Hoc Distributed
Queries', 0
GO
RECONFIGURE with override
GO
EXEC sp_configure 'show
advanced options', 0
GO
RECONFIGURE
GO

Presenting a "Pretty" date

I typically date my items as

01/15/2008 for January 15, 2008.

Here is a pretty way of transforming this:


SELECT , CONVERT(VARCHAR(12), ExpDate, 1) AS Expires


-- create a #session table so it will be cleaned up when
you close out of the window

INTO [#Oneyear]
FROM Mytbl

Wednesday, April 2, 2008

Try Catch with RollBack

BEGIN
TRY

BEGIN TRANSACTION
-- Update blah blah blah
-- If we got to this point, we are good
COMMIT

END TRY


BEGIN

CATCH
-- Thank you GuysFromRolla for this code.

IF @@TRANCOUNT > 0
ROLLBACK


-- Raise an error with the details of the exception.

--note: * I have heard ASP.NET will give the Raiserror message...


DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
SELECT @ErrMsg = ERROR_MESSAGE(),@ErrSeverity = ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)


END
CATCH

END

OPENROWSET for Excel File.

  1. Create a Linked Server
    - Server Objects --> Linked Servers --> Right-Click --> New Linked Server...
    - name the linked server MSDASQL
    - Provider is: Microsoft Jet 4.0 OLD DB Provider
    - Product Name: Jet 4.0
    - Data Source is the location of your excel file (include the file name? it has been a while...)
    - Provider String: Excel 8.0
Then if you run this:

SELECT *
INTO
tmpRaw_tbl
FROM

OPENROWSET
('MSDASQL', 'Driver=Microsoft Excel Driver
(*.xls);DBQ=C:\Company Folders\CorporateUpload\sub\subs.xls;'
,
'SELECT * FROM [Sheet1$] WHERE [MyCol] NOT LIKE ''blah%''')
AS derivedtbl_1


It will render this:
SELECT * FROM tmpRaw_tbl

There are a few reasons why you would get a NULL return string error.

  1. the file may be open
  2. file name is wrong (or the location)
  3. you have to hae [Sheet1$] in brackets with the dollar sign in order for the Jet Engine to read the file.

Other interesting things

Look up schema.ini formatting. You can define what each column format is, according to Jet standards...