Monday, June 21, 2004

.Stories of a .NET Newbie (5)

Today there was another of these learning moments. I have this Public Class where I store all my global business related code. Now what I did was defining my first Public Function CheckCredentials(ByVal username As String, ByVal hPassword As String) which, AFAIK, can easily be called by:

CheckCredentials (txtUsername.Value, hPassword)

However, running the code produced another runtime error

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I took me awhile to find the origin of the error. This was mostly due to the fact that I thought the function was called with the right parameters. After some testing I realized the function needed to be shared, e.g. make it Public Shared Function

Somehow, one hopes that troubleshooting with in the end become easier, after one has done his fair share of it. But it turns out every time that there's always a new error to be learned from

Friday, June 18, 2004

UPDATE: .Stories of a .NET Newbie (4)

1) Starting today I'm using Charles Carroll's Utility Belt ASP.NET library. It's been long since I've seen something so easily incorporated into a development project. And the way .NET handles libraries is just cool. Of course you could just as easily add you own classes, dll's and what not in VS6, but now it just seems so much easier.

2) Cast is giving me the creeps. In ASP doing something like Response.Write varname was a very easy way to put some Session variable or whatever to an asp page. But now, you put a label on the right spot on you page, and then you add to the code-behind:

lblUser.Text = Session("username")

At least, that's what I thought. lblUser.Text Is obviously a string, just like the Session variable. Nope. System.InvalidCastException: Cast from type 'HtmlInputText' to type 'String' is not valid

.NET *really* is an adventurous travel for me...

UPDATE: I'm feeling such a 'n00b' because after just a little reading about sessions I realised you can just as easy bind Objects to a Session. And that was exactly what I did with the following code :)
Session.Add("username", txtUsername)
txtUsername.Value would have been a lot better...

Tuesday, June 15, 2004

TechEd Europe 2004 is coming to town

Rumours all around the globe, now that the Web Application of the TechEd Europe 2004 has gone live yesterday. Inside the app you'll get a temporary email account on Outlook Web Access 2003 (which is looking *very* slick, b.t.w.). Also, there's the possibility to make a complete schedule of the conference, as the complete program is now finilsed and accesible. I must say, I neede almost 2 hours to read through all 300+ programs and make a desicion on which one to visit.
Sometimes I really want to be at 3 places simultaneously...

.Stories of a .NET Newbie (3)

1) From the MSDN Help:

"Applications that implement role-based security grant rights based on the role associated with a principal object"

Well, it sounds less hard than it is actually; at least to me. This Principal thing is a completely new concept to me. I know Users and the use of adding them to Roles of course, but first I totally couldn't grasp why one would use something on top of the User/Role scheme. Well, something to dig into some more the coming days.

2) Man, has Data handling become a simple matter. I'm communicating with my SQL Server now without having written any line of code, right from within my web pages! I always used something like the following to make a custom connection:

Set rst = New ADODB.Recordset
Rst.LockType = adLockOptimistic
Rst.CursorType = adOpenKeyset
Rst.Open "SELECT * FROM MyTable WHERE user = " & verifiedString & "'"
Do Until Rst.EOF
Set Rst = Nothing

But now... I opened up the Server Explorer, use the GUI to add a new connection to the SQL Server in the IDE. After entering the password the whole wealth of SQL Server unfolds itself right into the IDE. I can even make table changes on the fly if I want. But, what you're basically doing to enable paging is the putting a Table or Stored Procedure to your form. This automatically adds a SqlConnection1 and SqlDataAdapter1 to the so-called component tray area. No with basically some right-clicking here and there you set up the database connection; set a couple of details like the numbers of rows on your page, the kind of record selectors, and you're done. No more debugging unnecessary, repeating code with lots of typos, or hidden errors which only show up at runtime etc, etc.

For the first time in years coding has become *real* fun again

Saturday, June 12, 2004

Sikko2Go LINKS

(all via Robert Hurlbut's .Net Blog )

Things I want to check out for myself the next week

About the Team software: I saw so many postings about it, that I just want to see for myself just what it is and how it works, not to use it in my own environment

Friday, June 11, 2004

.Stories of a .NET Newbie (2)

And the story continues...:

1) I tweaked the web.config settings a little bit, more precisely in the authentication section. Immediately the IDE came up with a big Microsoft Development Environment "Error while trying to run project.. etc" and mumbling on for a couple sentences about all kinds of things not being OK. Me knowing I only changed some lines in the web.config, pressed Ctrl-Z until I was back from where I started, and everything was OK. Then I realized you can watch the web.config -being an XML file- in 'xml' mode and in 'data' mode. Now I know I should, after changing something here, first check data mode to see whether we're speaking well formed XML here. The 'data' mode will tell you did. Or is there a better way. I don't see any options to further kind of debug the web.config file?
Anyway, be careful with your brackets here.

2) Wow, I thought: .NET does data paging automatically now. Let me just put this DataGrid1 on my Form, set AllowPaging to True and PageSize to 5; run it!. Well, another .NET error popped up telling me "System.Web.HttpException: Control 'DataGrid1__ctl9__ctl1' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server."
The funny thing is that the datagrid pulled it's data from the SQL Server with no problems without paging. So I wouldn't expect an error like this. But well, the message is actually quite clear, so it should be fixed in a sec. So I switched over to 'html' view to see that the DataGrid was automatically placed in a Web Form already present on the page. So cut-n-paste it out of here, surround it with some form tags <form runat=server> and there you go. Only, what happens next is that I have page one with records 1-5, and clicking the 'next' doesn't yield records 6-10 which are clearly present in the table. The page refreshes only to come up with the same 5 records again, and no error message.
What to do now? This desperately calls for an event handler. But after having added some code to the DataGrid1_PageIndexChanged Sub in which the PageIndexChanged property decides to load a NewPageIndex, the Grid disappears from my screen when going the second page. Hmm... do I go on on this path, or am I heading in the wrong direction, meaning I should stop and start again from scratch? This is oftentimes a difficult desision to make for me. Well, I'm stopping this entry now 'cause I have to fix something and don't want to bore you with more of these details which are surely quite uninteresting to you, o highly experienced .NET developer.

Thursday, June 10, 2004

.Stories of a .NET Newbie (1)

Lately I've been doing some development in VS.NET 2003 every day now, so I thought I 'd start writing about it. There's just so much things to the language, and almost everything I do in the wonderfully overloaded IDE is new for me. It feels kind of 'fresh' for me after working for years with Visual Studio 6. Well, let's not spend too much words here, just give it a start.

1) This morning I realised I opened a Web Project on the local disk, which is not very good in case it's crashing. To overcome file loss, I sometimes do things like zip directories and place the zips on a network drive, labeled with some identifier (mostly the current date). But I figured there should be some option to transfer all a solution's files to another drive.
My eye immediately fell on the / Projects / Projectname Properties menu option. There you find an option 'file share', which can be changed. It was no problem to change it. However the next time I opened VS.NET I got a 'Web Access Failed' complaint from the system about localhost/webproject1 and this file share not matching. Well, I can imagine that. But how have the virtual directory point to the new location. Or rather, would I be able to do that: will that be enough and will I be out of additional problems... first lemme put the original File Share location back, to get back to the initial -working- setup.
There is a more general IDE wide option under / Tools / Options / Projects / Web Projects where you can change "Offline Projects" which is the location of the web project cache. Unfortunately, not everything is cached there, I only found some dll's, resource and debug data. No source code, which is my only interest. So out of luck again.
Then: let's just copy the projects' files over to the network location and create a fresh blank solution to which you add this project. This in turn yielded the error "the web server reported the following error when attempting to create or open the web project located at the following url: 'http://webserver:/WebProject1'. A connection with the server could not be established'. Well, for the time being I give up.
2) Markus Renschler's Rexexp Builder I needed something to get my regexes correct. I'm a total Regex n00b, and I don't have the time to become an expert in it. Only need them every now and then. But still, it's *very* difficult to produce even the simplest of expressions when you're not at ease with the syntax. What I needed was a check on a username being entered into a Web Form: it should only contain letters (small and/or CAPITAL). So I though it should be something like [azAZ]. Well, in the end it turned out to be ^[a-zA-z]+$ Which is not something the builder will come up with on it's own, but it's still a very convenient tool to quickly check some expression. Otherwise I would have had to change it in the IDE, rebuild the Solution and check on the web page whether it worked (And before you complain: I'm not using Unit Tests -so far-, making NUnit not an option here)
Last minute note: Chris Sells has a real RegEx builder tool which is a little bit more elaborate: after creating a regexp you can also generate VB/C# code for including the specific exp in your own application; handy

Sikko2Go LINKS

Report on Symbiots iSIMS counterstrike software. I thought about it back in March after having read their report on the rules of engagement in cyber war (thought I even wrote a little about it but that turned out not to be the case; I only commented here and there). They think one has the right to strike back when under (DDOS)-attack. But the problem lots of experts see is that the internet can be congested once everybody is using these techniques. And Symbiot's advice to only use counterstrike when all else fails is just like handing a dictator an nuclear bomb whilst telling him he should only use it when.. Well, all else fails.
worrisome development. And hey: USD10,000 a month for this service, isn't that a bit too much??

Monday, June 07, 2004

Weirdest Search Engine hit so far

Yesterday I received quite a strange hit to this blog. From MSN someone was looking for shopping in disneyworld. Now, probably there's a lot of mugs and puppets you can buy over there; but I can't remember having *ever* written about shopping, nor Disneyworld. So they probably did not find what they were looking for. Still, I'm grateful for the traffic from MSN, because there's not much coming from there. Search engine related traffic is still about 90% coming from Google

Friday, June 04, 2004

It was an efficient day ...

  • finalized a couple of MS Access data entry screens, which were being tested using our standardized test protocols for these screens.

  • Did an install of the IIS 6.0 Resource Kit, although I have to say it will take another day to look into all options it gives me. Right now it only looks overwhelming. For example, right now I can't think of some concrete use for editing the Metabase. But maybe that will come with time.

  • Took about two hours to do some VB.NET practice. I'm very glad that finally I find a bit more time for going into .NET coding. Right now there's no in-houses application we've done in .NET, as it's still all Studio 6. But I think it's getting more and more important to get into the new direction more

  • the DLT tape streamer was causing problems... again. Yesterday I put the /verify option back on. Our backup server is Server 2003 now, and we found out the backup process is much more efficient now, giving the possibility to do a complete verify after a full backup, and still finish hours before someone arrives in the office. Took me more than an hour to get the streamer back online, with a cold reset in the end. Still don't know what really was the problem, but this thing is taking me more time than I like.

  • Had a little more than an hour to do some development on my Secure Web project. But with the weekend already neigh, I wasn't that efficient anymore at that time.

  • Tonight I read some more Paul Graham essays. His newest essays are mainly about new spamfilter techniques (of which the Bayesian technique seems to yield the best results). Older articles, some very lengthy, handle about his clear passion for succinct programming languages, the ones that are able to the same with less code. Lisp is clearly his language of choice. Although I've never looked at the language before (maybe I should... do I feel another entry coming?), the general ideas in the articles are very refreshing - to me at least - and had me thinking about the place .NET takes in there (it's nowhere mentioned in his articles), and giving me a broader view on the world of programming languages. I learned mainly Visual Basic, along with some JavaScript / VBScript, which is a world away from his one. Still: highly recommended stuff (mmm, Lisp looks so condensed it's really gibberish for me. This places .NET somewhere in the middle on the scale, right next to the Blub language I guess :)