Search this insane blog:

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