Feed on
Wpisy
Komentarze

Did you know that your burner can make label on a cd or dvd? you need just to turn round your disc and make a label :)

More at: http://www.chip.pl/arts/archiwum/n/printversion/printversion_170098.html (Polish)

DataReader and DataAdapter

Thanks to Gosia I got interested in ADO.NET objects like DataReader and DataAdapter. So what are they and how are they better from simple methods?

DataReader can retrive read-only, forward-only stream of data from a database and they are stored in a buffer on client side even if not all query have been executed yet. You use the Read method of the DataReader object to obtain a row from the results of the query. You can access each column of the returned row by passing the name or ordinal reference of the column to the DataReader.

Everything and more you can read at MSDN: http://msdn.microsoft.com/en-us/library/haa3afyz(VS.71).aspx

Here is an example from MSDN:

The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. There are also inherited classes like: OdbcDataAdapter, OledbAdapter, SqlDataAdapter and so on to each supported database. Se more at MSDN site: http://msdn.microsoft.com/en-us/library/system.data.common.dataadapter(VS.71).aspx

Here is an example from MSDN:

So what is the difference?

  • dataReader can’t make update in a database, it can only read, dataAdapter has Update method,

  • dataAdapter is easier to use

  • you can’t serialize a dataReader so you can’t remote it

  • dataAdapter provides dataSet, that has great functionality, allow you manage DataRelation, Dataviews, DataTable.Select, Expression Columns etc.

  • dataReader is faster when you read large record set

I found very nice comparison of this two at: http://msmvps.com/blogs/williamryan/archive/2005/02/26/37015.aspx

It’s easy to draw and manage shapes in Expression Blend, but when it comes to generate shapes automatically we realize that it’s much harder. Lucky for us all properties can be set in code and all shapes can be drawn.

First we have to have canvas to draw on:

When we got that we can write some C# code, and create a path.

But what is this Path.Data property? This is list of points in Path Markup Syntax. You can learn more about this language here: http://msdn.microsoft.com/en-us/library/bb412389.aspx

Here is an example of elipse as a data for path variable.

Another nice thing is that we can add anything we want from code. Let’s add linear gradient brush. First we must define gradient stops and set it’s color and offset – place where color will appear(value must be between 0 and 1). Then we have to create LinearGradientBrush and add stops to its gradientStops collection. Remember to set StartPoint and EndPoint properties of linear gradient brush. This is where gradient will start and end. And don’t forget to set Path.Fill property and assign our brush to it.

And the result should look like this:

And last bu not least it’s drawing lines. After drawing ellipse drawing line should be piece of cake, but at the other hand it’s very useful.

Again we create Geometry object, which is called LineGeometry, set it’s start and end point and assign that object to our Path.Data object.

The result you should see below:

The main issue is that SilverLight does not fully support debugging your project. So it won’t tell you what you did wrong, it only tells you that somethings wrong. Check your XAML code again and look especially for things you could forget, for example implement click event handler:

Check if there’s no values that cannot be less than 0. And if all fail go and write your code again with VS and intelliSense.

Theres a problem with accessing files from disc in Silverlight, because it’s prohibited.

So code like this:

will cause an exception: expected relative uri, found absolute

You might try to add the following:

But it will also cause an exception: Attempt to access the method field: File.Open

So SilverLight prohibit access to files on your computer, so you can pass this file trough Web Service, or dll file or you can just create text box and get XML file from it. Code will look like this:

słuchacie Paktofoniki?

Bo ja jestem Bogiem
Uświadom to sobie
Słyszysz słowa od których włos jeży się na głowie
O rany rany
Jestem niepokonany
Ha I Pe Ha O Pe
Bez reszty oddany
Przejebany
Potencjał niewyczerpany
Chyba w DNA on był mi dany
Czekaj Fokus, Rah
Jeszcze oszaleją wszystkie pizdy
Gdy poznają mój urok osobisty
Duszę artysty
To jaki jestem skromny i bystry
Szczery do bólu
Że aż przezroczysty
I wiesz co mnie boli
Że w głowach się pierdoli
Zakłócony
Pokój ludziom dobrej woli Jestem Bogiem
Uświadom to sobie
Ty też jesteś Bogiem
Tylko wyobraź to sobie