Archive

Archive for August, 2012

microsoft.net framework 2.0 sp2 is required for SQL Server 2008 installation in Windows Server 2008 64 bit

August 12, 2012 1 comment

I  spent some time to get it done. When you download and install microsoft.net framework SP2 it will show microsoft.net framework SP1 is required. If you installed sp1  it won’t work i think (i didn’t get it) .

To solve the issue

download and install

http://www.microsoft.com/en-us/download/confirmation.aspx?id=22

need internet connection to get it installed.

Now you can install SQL Server 2008 without any problem

🙂

Advertisements

SqlDataReader to JSON string

August 9, 2012 Leave a comment

We can easily parse the SqlDataReader object to a JSON string , see the below code

private string WriteReaderToJSON(StringBuilder sb, IDataReader reader)
{

if (reader == null || reader.FieldCount == 0)
{
sb.Append(“null”);
return “”;
}

int rowCount = 0;

sb.Append(@”{“”Rows””:[“);

while (reader.Read())
{
sb.Append(“{“);

for (int i = 0; i < reader.FieldCount; i++)
{
sb.Append(“\”” + reader.GetName(i) + “\”:”);
sb.Append(“\”” + reader[i] + “\””);

sb.Append(i == reader.FieldCount – 1 ? “” : “,”);

}

sb.Append(“},”);

rowCount++;
}

if (rowCount > 0)
{
int index = sb.ToString().LastIndexOf(“,”);
sb.Remove(index, 1);
}

sb.Append(“]}”);

return sb.ToString();

}

Categories: ASP.NET Tags: ,