Archive for the ‘General Technology’ Category
The custom tool ‘MSLinqToSQLGenerator’ failed. Unspecified error
There is an issue in Microsoft’s latest SP1 for Visual Studio 2008. If you have a partial class with Using statement at the top of the file for a Linq-To-SQL Data Classes context object. You will get above error. Visual Studio will delete the corresponding “.designer.cs” file for your data context and nothing will be compiled.
To solve this issue, you may have to move “Using” statements inside namespace declaration. This is a workaround provided by Microsoft.
A circular reference was detected while serializing an object of type …
I ran into an issue earlier when trying to serialize an object return by LINQ. After Googling it, I found following blog which is very helpful.
I believe this is a common issue for LINQ objects and hope this blog can save time for somebody.
I cannot login to my SQL Server database anymore!
When you attempt to login to your database using SQL Server Authentication and you get an error message that says:
Cannot open user default database. Login failed. Login failed for user ‘usrLogin’. (Microsoft SQL Server, Error: 4064)
It might possibly be due to the fact that the database that was set up to be the default for that specific login has been deleted.
What you need to do is update the login to have a default database that you know exists. Here’s how to fix it. Open a command prompt and type the following:
For SQL 2005:
osql -S SQL01 -d master -U usrlogin -P usrpassword
ALTER LOGIN usrlogin WITH DEFAULT_DATABASE=new_default_db
For SQL 2000:
isql -S SQL01 -d master -U usrlogin -P usrpassword
(opens query analyzer, type the next line in there)
sp_defaultdb ‘usrlogin’, ‘ new_default_db’
If this didn’t fix the problem… try this link:
http://benharrell.wordpress.com/2007/01/15/cannot-open-user-default-database-login-failed-login-failed-for-user-username-microsoft-sql-server-error-4064/
Kiosk Applications
Kiosk applications and other self-service systems are rapidly growing business area. Internet connectivity, a greater variety of interface equipment and prices that continue to drop are enabling the cost-effective deployment of an ever widening array of applications. Hardware is available for a wide spectrum of requirements. Vendors such as NCR and 5point can meet most any need
Kiosk Software application development is relatively straightforward. Many kiosk applications now use an ordinary PC attached to various more specialized interface equipment such as touchscreens, card readers, special keyboards, and trackballs. Equipment and kiosks can be purchased for either indoor or outdoor usage, outdoor equipment is noticably more expensive. Outdoor kiosks have special needs due to weather, water and sunlight.
Usually either .NET or Java is used as an application language. The operating system is either Linux or Windows XP. Kiosk applications can be a specialized web site program or more traditional client application. There are special security programs for controlling access and monitoring the kiosks (such as Kioware). These programs prevent access to the computer or any application other than those specifically permitted.
Touchscreen applications are much like any other except the interface elements typically have to be much larger. This can be especially challenging when working with spreadsheet like programs or interfaces. Most interface hardware available today has a well defined software API and can usually interact seamlessly with the programming.
Unidev recently completed two separate kiosk applications. One was an application which allowed visitors to search a large database of products and images to obtain detailed information about the products and pricing. By automatically providing this information on a round the clock basis, the vendor is able to interact with all potential customers even when salespeople are not available.
The other application provides an automated method for filling out and validating data entry forms by customers. This application saves a considerable amount of labor as well as ensures the data is correctly filled out and validated while the customer is on site saving considerable rework.
Both of these applications communicate with a central server for obtaining updates of both code and data, sending report information to the server and monitoring. The server applications provide a central data collection point for management reports.
Self-service kiosks have proven themselves to be a cost effective tool for both labor savings and improving service levels to customers.
Improve ASP.NET Performance and Scalability
Do you have performance issue on your ASP.NET website? Do you want to boost your site’s scalability? Do you know the bottleneck of your site? Do you want your site performs well under 100 times more traffic? Here are some good posts about this:
10 ASP.NET Performance and Scalability Secrets
Boost ASP.NET performance with deferred content loading
Using UTF-8 in Ajax, PHP, MySQL & ASP.NET
We have a project which needs to show foreign language, like Chinese, on a web page. And we are using RICO 2.0, PHP, MySQL & ASP.NET in the project. To achieve this, we decide to use UTF-8 character set and the following changes need to be done:
- MySQL:
To store UTF-8 in a table field, you need to set column’s charset => utf8 and collate => utf8_unicode_ci
- Web Page:
To show foreign language in a web page, the page file has to be saved as encoding UTF-8
- PHP:
The default encoding for PHP 5 is UTF-8, so it supports foreign language. But if you use PHP to retrieve UTF-8 characters from MySQL, you must add mysql_query(‘SET NAMES utf8′); after connecting to MySQL database for setting up the connection encoding.
- RICO:
As for RICO Live gird, Ajax response must start with <?xml version=”1.0″ encoding=”utf-8″?>
- ASP.NET:
First make sure you have following line in you web.config
<globalization requestEncoding=”utf-8″ responseEncoding=”utf-8″ fileEncoding=”utf-8″/>
Second, keep both .aspx and code behind file save as the same encoding UTF-8
If you need to access the UTF-8 characters in MySQL database, be sure to use MySQL Connector/Net 5.0 or up with undocumented setting: charset=utf8 in connection string. We tried ODBC driver for MySQL, it doesn’t work properly with UTF-8.
Add Interactive Map to your website using Google Maps API
Interactive maps has become an inevitable part of modern web applications and introduction of Google Map API has made it even easier to integrate an interactive map to your website. Areas on which interactive maps have proved itself are tourism related websites and service oriented websites. In this blog we will see how we can add an interactive map to your website using Google Map API and AJAX to process the response from the server.
The first step in integrating a map in your website is to request a Google map API key. You can request a Google Maps API key here. If you have URL for your website, you need to specify the URL while requesting key. If you are playing around with the API, you can very well request for http://localhost. If you are using a port number , you need to specify the port number also. For example http://localhost:8080. Once you get the key you can use the key for all subfolders of http://localhost.
This is Source of an HTML page that displays map of 1415 Elbridge Payne Rd,Chesterfield,MO 63017. You need to know the latitude and longitude of the address to display map in your web page. If you don’t know the latitude and longitude , there are many online services that provide services to get latitude and longitude of an address . Another way of implementing this is to use geoCoder provided by Google Map API to get the latitude and longitude by providing an address. We will come to this in a while.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”content-type” content=”text/html;
charset=utf-8″/>
<title>Google Maps JavaScript API Example</title>
<script src=”http://maps.google.com/maps?file=api&v=2&key=
ABQIAAAAR7yXyXxWnmYNsvbV6JWv5hT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTvGi- GhomVbgkbC6tv2C8JocyNEg”
type=”text/javascript”></script>
<script type=”text/javascript”>
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(38.65, -90.56), 8);
map.addControl(new GSmallMapControl());
map.addControl(new GOverviewMapControl());
var point = new GLatLng(38.65, -90.56);
marker = new GMarker(point);
map.addOverlay(marker)
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<p>Unidev: Custom Software and Applicaton Development</p>”});
}
}
//]]>
</script>
</head>
<body onload=”load()”>
<div id=”map” style=”width: 800px; height: 600px”></div>
</body>
</html>

Class GMap2 represents a map instance and you can create as many instances as you want. addcontrol() method can be used to add controls to your map.GSmallMapControl() enables Zoom functionality. Event handling is implemented using GEvent.addListener() method. GMarker class marks a point of interest in your map.OpenInfoWindowHtml() method opens an informational window on ‘OnClick’ event. Place holder for map in this example is a <div> tag with id ‘map’.
Adding an Interactive Map to your web application:
This example shows how to add a user driven map in your web application. First step in creating an interactive map is to have a form in your web page where users can enter the address and description of their point of interest.
Given below is the bean and DAO implementation class.
public class GMarker
{
private Long id;
private String address;
private String description;
// Need to have setters , getters and a costructor that takes all the varaibales)
}
We have another Location object that stores data entered by users. We read data from the Location table(which is populated by the data submitted by users) and create Gmarker object. This DAO implementation is not Table driven , we read hardcoded data from a Map. In realworld DAO Implmentation would be Table driven.
DAO implementation:
public class PickDAOImpl implements PickDAO
{
private static final Map myPicks = new HashMap();
static {
myPicks.put(“1″,new GMarker(new Long(1),”1415 Elbridge Payne Rd,Chesterfield,MO,63017″,”Unidev: Custom Software and Application Development”));
myPicks.put(“2″,new GMarker(new Long(2),”1400 Douglas Street,Omaha,NE”,”Union Pacific Railroad”));
}
public List findAllAsMarkers() {
List results = new ArrayList();
Collection allLocations = myPicks.values();
Iterator locIt = allLocations.iterator();
GMarker location = null;
while(locIt.hasNext()){
location = (GMarker)locIt.next();
results.add(new GMarker(location.getId(),
location.getAddress(),
location.getDescription()));
}
return results;
}
}
Heart of Ajax is XMLHttpRequest object and however in this example we are using Google’s version of XMLHttpRequest object, that is GXmlHttp class. Ajax makes the request to the servlet, which would be processed by the servlet and Servlet returned XML Document object can be processed by Javascript DOM functions. We are using Xsteam implementation provided by http://xstream.codehaus.org/ to generate XML document from Java object. Other open source libraries like Apache and Castor can also be used to generate XML document from Java objects.
XML document generated by the servlet for the request to get all user submitted addresses in the database would look like this.
<list>
<marker>
<id>2</id>
<address>1400 Douglas Street,Omaha,NE</address>
<description>Union Pacific Railroad</description>
</marker>
<marker>
<id>1</id>
<address>1415 Elbridge Payne Rd,Chesterfield,MO,63017</address>
<description>Unidev: Custom Software and Application Development</description>
</marker>
</list>
Given below is the Servlet that generated the above XML document.
public class MyPickServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
{
private PickDAO pickDAO;
public PickDAO getPickDAO()
{
if (pickDAO == null) {pickDAO = new PickDAOImpl();
}
return pickDAO;
}
public void setPickDAO(PickDAO pickDAO)
{
this.pickDAO = pickDAO;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String method=request.getParameter(“method”);
XStream xstream = new XStream();
xstream.alias(“marker”, GMarker.class);
response.setContentType(“application/xml”);
if (method.equals(“findAll”)) {
List locations = getPickDAO().findAllAsMarkers();
String xml = xstream.toXML(locations);
response.getWriter().write(xml);
}
}
The response generated by the Servlet is processed by javascript DOM functions. Given below is the HML page, that makes AJAX request to Server and process the response from the Server. The Javascript code has comments added to explain the important points.
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
<title>Google Maps JavaScript API Example</title>
<script
src=”http://maps.google.com/maps?file=api&v=2&key=
ABQIAAAAR7yXyXxWnmYNsvbV6JWv5hT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTvGi-GhomVbgkbC6tv2C8JocyNEg”
type=”text/javascript”></script>
<script type=”text/javascript”>
var map = null;
var gmarkers = [];
var i =0;
var address = null;
var geocoder = null;
var id = null;
// method called on onLoad event
function loadUserPicks() {
map = new GMap2(document.getElementById(“map”));
var request = GXmlHttp.create();
request.open(“GET”, “myPick?method=findAll”, true);
request.onreadystatechange = getCallbackFunction(request, processGmapData);
request.send(null);
}
function getCallbackFunction(req, processData) {
// Return an function that listens to the
// XMLHttpRequest instance
return function () {
// If the request status is “complete”
if (req.readyState == 4) {
if (req.status == 200) {
// Got a response
// Pass the XML payload of the response to the
// handler function
processData(req.responseXML);
} else {
// An HTTP problem has occurred
alert(“HTTP error: “+req.status);
}
}
}
}
var locMarkers = null;
function processGmapData(xmlDoc){
// obtain the array of markers and loop through it
locMarkers = xmlDoc.documentElement.getElementsByTagName(“marker”);
displayPicks();
}
function displayPicks() {
map.clearOverlays();
for (var i = 0; i < locMarkers.length; i++) {
// obtain the attribues of each marker
var label = locMarkers[i].getElementsByTagName(“address”)[0].firstChild.nodeValue;
address = label;
map = new GMap2(document.getElementById(“map”));
// Create new geocoding client object
geocoder = new GClientGeocoder();
// Retrieve location information for the address, pass it to addToMap()
geocoder.getLocations(address, addToMap); }
}
function addToMap(response)
{
// Retrieve the object
var place = response.Placemark[0];
// Retrieve the latitude and longitude
var point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
// Center the map on this point
map.setCenter(new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]),4);
map.addControl(new GSmallMapControl());
map.addControl(new GOverviewMapControl());
var marker = new GMarker(point);
GEvent.addListener(marker,”mouseover”, function() {
marker.openInfoWindowHtml(place.address + ‘<br>’+'<b>Country:</b>’
+place.AddressDetails.Country.CountryNameCode);
});
gmarkers[i] = marker;
i++;
map.addOverlay(marker);
}
</script>
<form name=”mypickform” action=”/myPick” method=”get”>
<body onload=”loadUserPicks()”>
<div id=”map” style=”width: 800px; height: 600px”></div>
</body>
</form>
</html>

Enjoy……
Possible Issue for hosting a Silverlight website
As we know, Silverlight is a portable client side technology and requires no runtime on the server. So moving a Silverlight app to a new server requires no server side configuration. But one point is important. If you don’t have .NET 3.0 framework installed on your new server, you may have to add a new MIME type for the website which hosting Silverlight. Otherwise the Silverlight will just refuse to work and show no clue what’s wrong.
Here are the steps on an IIS server:
Start -> Run -> type inetmgr to open iis manager.
Then rigth click on your site and click properties. After that choose tab Http Headers and there you will see button MIME Types … click it and add xaml in textbox.

