Monday, August 13, 2007

IE7's absolute positioning problem when overflow is auto

Recently, I was faced with a weird absolute positioning problem that only happen in IE7. Basically, I have several span tag with absolute position inside a div tag with "overflow:auto", it displays correctly in IE6 and Firefox 1.5 onwards, the object was positioned perfectly. The problem arise when one of our customers upgraded their browser to IE 7 and reported the problem, where text appear all over the places. "The problem doesn't happen until we scrolled further down to the div area wasn't visible initially."  It was quite some time to discover the cause of the problem, pasting the HTML to W3C mark up validator (http://validator.w3.org/) and no problem found. I tried to change the overflow from auto to "overflow:scroll" and the problem gone.

I finally ended up setting a different style for IE7, there is a good reference on how to set CSS to specific browser http://www.webdevout.net/css-hacks#in_css-hyphen.

Anyway, if you have a problem with web page's positioning and it only happen in IE7, it worth to try the solution above and hopefully the problem goes away.

Wednesday, February 01, 2006

BC30251 has no constructors

Finished developing and testing on the local machine (XP), I uploaded the latest change to the staging server running windows 2003, using the web deployment add in for VS 2005. Try to test the application an error is thrown advising that one of the user control doesn’t have a constructor. The error code was BC30251. Find the reference: http://msdn2.microsoft.com/en-us/library/s6zx0et2.aspx

A type does not support a call to Sub New(). One possible cause is a corrupted compiler or binary file.

Error ID: BC3025

To correct this error

1. If the type is in a different project or in a referenced file, reinstall the project or file.

2. If the type is in the same project, recompile the assembly containing the type.

3. If the error recurs, reinstall the Visual Basic compiler.

4. If the error persists, gather information about the circumstances and notify Microsoft Product Support Services.

Tried to recompile the application and redeploy it again doesn’t work. I tried to avoid as much as possible to reinstall the .NET framework or VS 2005. I commented few lines of code inside the user control, try again to deploy in the same way, and it worked! Finally, I moved few lines of code to other utility (helper class) and the application went perfect. Just another fun thing with new stuff .

Sunday, December 04, 2005

@@Identity Equivalent in MySql - Getting Last Inserted ID in MySQL

As a .NET Developer i really get used to Sql Server until I got a small project that require me to developed with MySql database backend. The first thing that I face with is to figure out the equivalent of @@Identity in MySql, got it , LAST_INSERT_ID() in MySql.

The second problem is how to return that function value to the application from the database. Since i am using a straight SQL. Then it turns out that below is my solution. I use execute scalar to retrieve the value of the last inserted id and use the usual executeNonQuery for update. Done.

Example:


comm = New MySqlCommand

param = New MySqlParameter("?MemberID", MySqlDbType.Int32)



If _MemberID = 0 Then

comm = New MySqlCommand("Insert Into Member(FirstName,MiddleName,LastName) VALUES (?FirstName,?MiddleName,?LastName);SELECT LAST_INSERT_ID();")

Else

comm = New MySqlCommand("Update Member( SET FirstName = ?FirstName,MiddleName = ?MiddleName,LastName = ?LastName) WHERE MemberID = ?MemberID; ")

End If

param.Direction = ParameterDirection.Input

comm.Parameters.Add(param)

comm.Connection = conn

With comm.Parameters

.Add(param)

param = New MySqlParameter("?FirstName", MySqlDbType.String)

param.Value = _FirstName

.Add(param)

param = New MySqlParameter("?MiddleName", MySqlDbType.String)

param.Value = _MiddleName

.Add(param)

param = New MySqlParameter("?LastName", MySqlDbType.String)

param.Value = _LastName

.Add(param)
conn.Open()

If _MemberID = 0 Then

_MemberID = comm.ExecuteScalar()

Else

comm.ExecuteNonQuery()

End If

conn.Close()