Friday, June 18, 2010

Buying G35 Coupe With 100000 Miles

Home Networking Problem with null fields with ASP.NET image SQL Error

Let me explain first that I'm moving stage and the steps I have taken to solve the problems of storing a null value in a field of type image in a SQL database.

The SQL database I have a table with a field of type image that supports zero.
In this same database I create a stored procedure to insert and update the table

From. NET created a Typed Data Set where I create a DataTable with the fields of the SQL table and I assign to each field's data type. In the case of image field I assign the data type. NET System.Byte (). I use this DataTable to load the fields from multiple tables in the SQL database.

When calling the stored procedure from. NET I would point out the parameters in a SqlCommand and execute it as ExecuteNonQuery.


At first glance all the steps are working properly and I have no compilation error.

First error happens when I try to save a null value in the image field


For the point where error occurs in the class is automatically generated from the DataSet. Is taking place in the column in the DataTable image I created. Occurs because when you create the image I left field in the properties indicated that generates an exception if it encounters invalid.

I see two options to avoid this error

  • The first is a change of ownership NullValue Image field so that instead of generating an exception when they contain zero, that does not give anything (is an option down in that field)

  • The second is to change the code where I add the parameter @ image. Instead of using a shortcut IIF which evaluates the two sides (and then skips the error) If using a separate, so that if the image is null, does not come to assess.
seems that everything is fine, but when we re-run with another error.
In this case the error is generated when running the stored procedure command. The first thing you notice is that the speech error data type nvarchar , we have not used at any time.
If you put a breakpoint and look at the picture we sent to parameter stored procedure surprise we found that the type of data we are sending is a nvarchar (SqlDbType).

This is because adding the parameter to the command does not indicate any kind of data, but only pass the parameter name and value

solution is an indication in the command parameter the sql data type is an Image

So if we repeat the performance we see in the inspection of the @ image the command has disappeared type nvarchar the image and everything is working correctly


Friday, May 28, 2010

My 5 Month Old Has A Dry Cough

is not allowed HTTP POST verb accessing an html page

This error can result for several reasons, but I'm focus when trying to access generates an HTML page using the property PostBackUrl a control button, ImageButton, or LinkButton in ASP.NET.

Normally the aim is to go from one page to another by pressing a button. Putting on the property control PostBackUrl the name of the landing page works, except that set the target to an html page instead of aspx.

This has to do with cross-page posting. NET (which allows access from one page to the controls on the source page.) Html pages can not process a form submitted with HTTP post and when we produce a postback (server request) default form is sent to landing page.

There are several ways to solve this problem
  1. Change the button for a hyperlink to the destination (which may cause the page layout change too much)
  2. Set the button's click event indicating Response.Redirect , the landing page and remove the value of the property PostBackUrl
In the case of an HTML button (input type = "button") can schedule the event onclic with javascript on the client

In the case of a asp.net button control of the programming we do in the code file
Some links to learn more about this topic:

Wednesday, May 26, 2010

Difference Between Fakan And Real Boobs

Transform an HTML page to ASPX

On more than one occasion we need to add controls. net to a static HTML web page. To do this, we need to transform this HTML in ASPX page and if necessary link to a page of code in Visual Basic or C #
We
1 A copy of the HTML page and rename the extension to ASPX.

2 Add the @ Page directive at the beginning of the code.

3 Added within the body tags in a form with runat = server property that contains existing controls on page




From here we have a fully functioning aspx page in which can use asp controls. net.

If you also want to use programming in Visual Basic or C # we have to make any further step.

1 Add to draft a new element of type Class (from adding new elements) and put as name the aspx page and as an extension aspx.vb aspx.cs Visual Basic or C #.


Default asks if we want to save this new file in the App_Code folder, and it detects that a file of code, we can say no and they nest under the aspx file we created in the previous step
2 Modify the code file class aspx.vb / aspx.cs indicating that it is a partial class that inherits the class
Pages




3 Indicate to the ASPX page, which is the associated code file and class. For this we modify the @ page by adding parameters and ClassName CodeFile



From now we have totally transformed the site and operational controls to work with both. Net and to use code (in this example) Visual Basic or C #

Before
After