Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, November 11, 2013

A network-related or instance-specific error occurred while establishing a connection to SQL server.[Solution]

When I tried to connect MSSQL server 2008 from Visual studio express 2012 web, it always return an error : "A network-related or instance-specific error occurred while establishing a connection to SQL server".
To solve the problem, go to start menu and search Services.
Run it and find "SQL Server Browser", change the Startup Type from "Disabled" to "Automatic" (if you don't know, right click on the item and choose properties).

After that Start the service(Right click and click start). The result should be same as below.

I also changed the startup type for "Sql Server Agent" from "Disabled" to "Automatic".

And try again the connection at visual studio.

If  didn't works, try ask google. :D
_________________________________________________________________
_________________________________________________________________

Saturday, February 18, 2012

Export Data Set/Data Table To Excel C# asp.net.

最近工作需要,写了一个可以把Data set的 structure 和 data export 到 excel format file的class。 这不是正统的export 方法,其实它是用HTML的structure 来构造需要的excel。 虽然如此,这 excel的功能还是能一样的。而且还蛮整齐的。
我把 code 放在 http://cjjack88.blogspot.com/p/fastexportexcelhelper.html。 大家可以一起研究研究。

这是export 出来的excel format。

其实这个class 还不不完美。 还有很多需要改进的地方。尤其是performance 方面。 

以下是一些示范如何使用这个class的code。

           DataTable demoDataTable = BuildDemoTable();
            using (FastExportExcelHelper myExcelHelper = new FastExportExcelHelper())
            {
                myExcelHelper.SetDataTable(demoDataTable);
                string[] isDecimal = new string[] { "Decimal" };
                string[] isDate = new string[] { "Date" };
                string[] isBoolean = new string[] { "Boolean" };
                myExcelHelper.IsBoolColumns(isBoolean);
                myExcelHelper.IsDateColumns(isDate);
                myExcelHelper.IsDecimalColumns(isDecimal);
                myExcelHelper.RenameHeaderName("NeedToRename", "After Rename");
                myExcelHelper.CreateFastExcel("Demo Excel", this.Response);
            }
        }
        private DataTable BuildDemoTable()
        {
            DataTable result = new DataTable();
            result.Columns.Add(new DataColumn("INT", typeof(int)));
            result.Columns.Add(new DataColumn("Character", typeof(char)));
            result.Columns.Add(new DataColumn("Decimal", typeof(decimal)));
            result.Columns.Add(new DataColumn("Date", typeof(DateTime)));
            result.Columns.Add(new DataColumn("Text", typeof(string)));
            result.Columns.Add(new DataColumn("NeedToRename", typeof(string)));
            result.Columns.Add(new DataColumn("Boolean", typeof(bool)));
            char isChar = 'C';
            decimal isDecimal = 100;
            DateTime isDateTime = DateTime.Now;
            string isString = "I am String .";
            string isRename = "RenameBa";
            bool iaBoolean = false;
            for (int i = 0; i < 1000; i++)
            {
                result.Rows.Add(i, isChar, isDecimal, isDateTime, isString, isRename, iaBoolean);
            }
            return result;
        }

我把demo 的files 放到media fire http://www.mediafire.com/?hq31ank883l2fzz。 有兴趣可以下载来看看。最后欢迎有建设性的意见。 
_________________________________________________________________
_________________________________________________________________

Monday, September 13, 2010

ASSIGNMENT:用 php + mysql 研发一个e-commerce系统

这个sem我有一科是web development,其中一个project就是替一家公司/商店开发一个网上预订/网购的系统。我们的组选了一间背包店,帮它研发一个网购系统。

首先,我们要清楚我们所开发的系统会有什么功能,使用者是谁,还有最重要的,是系统的保安一定要到家,因为它涉及你的client的资料和金钱。如果有保安漏洞,那么这套系统的interface做到几美都没用。
还有,我发现一些同学的concept错了,因为他们担心client的product太多,要帮client 输入资料会很麻烦。第一,我们只是developer,我们只开发一套系统给client,我们完全不用帮client输入product的资料,可能只需要key in几个来test我们的系统。而且client也不会随便把公司product的资料交给我们。而且想想,如果client在明天有新的product到,难道client要call我们帮他们输入这些product的资料?
所以,我们的系统一定要有ADD, REMOVE和MODIFY的功能。这系统一定会有一个database,然后我么就要设计一些interface让user去add,remove和delete database里的data。例子:当有新的product时,user就要进入add page去输入这些新product的资料。当这product没有了货或者是停止售卖时,user就要去remove page删除这product的资料。当这product补货时,就要去modify的page更新货物的数量。这些功能一定要设计只能让管理层(admin)使用。
还有view的功能,让user能游览所有product。
我们先明白一些网店的运作流程吧。
1. 一个顾客游览网店,
2. 他游览网店的网页,点击网页上的产品。
3. 他阅读产品的资料,对产品有兴趣。
4. 点击“add to cart”,把产品加入购物栏(shopping cart)。
5. 他结帐,输入邮寄地址,付费资料。
6. 他离开网店。
嗯,就是那么简单。这就是大家要做的基本功能,就是网店该有的网页让顾客能做完以上6个步骤。当然,你能够为你的网店加入更多的功能,比如多预订之类的,但是我们还是先focus在basic的功能。
下面是我为网店做的data flow diagram。还在学习中,不懂做得对不对。
还有一个use case diagram,就是哪些user该享有哪些功能的使用权。


至于开发网店所用的语言,我选用php,因为语法比较简单(对我来说),还有很容易找到免费的web hosting。database方面就选用mySql。原因一样。^.^v

先写到这,要睡觉咯~大家加油加油!!!
_________________________________________________________________
_________________________________________________________________
看看这个php的code,是view all product的code。
<?php

$con = mysql_connect("localhost","root","");

if(!$con)
{
die('Could not connect: ' .mysql_error());
}

mysql_select_db("bagman_ecommerce", $con);

$result = mysql_query("SELECT * FROM product");

echo "<table border='1'>
<tr>
<th>No.</th>
<th>Product id </th>
<th> Product name</th>
<th>SKU</th>
<th>Quantity</th>
<th>stock Status</th>
<th>manufacturer id</id>
<th>shipping</th>
<th>Price</th>
<th>Date available</th>
<th>Weight</th>
<th>Length</th>
<th>Length class</th>
<th>Width</th>
<th>Heigth</th>
<th>Weight class</th>
<th>Date added</th>
<th>Date modified</th>
<th>Viewed</th>
</tr>";
$no = 0;

while($row = mysql_fetch_array($result))
{
$no = $no + 1;
echo "<tr>";
echo "<td>" . $no."</td>";
echo "<td>" . $row['product_id']."</td>";
echo "<td>" . $row['product_name']."</td>";
echo "<td>" . $row['sku']."</td>";
echo "<td>" . $row['quantity']."</td>";
echo "<td>" . $row['stock_status_id']."</td>";
echo "<td>" . $row['manufacturer_id']."</td>";
echo "<td>" . $row['shipping']."</td>";
echo "<td>RM " . $row['price']."</td>";
echo "<td>" . $row['date_available']."</td>";
echo "<td>" . $row['weight']."</td>";
echo "<td>" . $row['length']."</td>";
echo "<td>" . $row['length_class_id']."</td>";
echo "<td>" . $row['width']."</td>";
echo "<td>" . $row['height']."</td>";
echo "<td>" . $row['weight_class_id']."</td>";
echo "<td>" . $row['date_added']."</td>";
echo "<td>" . $row['date_modified']."</td>";
echo "<td>" . $row['viewed']."</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

Tuesday, June 15, 2010

学Java第一章:你需要的工具


在你开始任何事情时,你需要在你的电脑安装以下两件东西:
1. The Java SE Development Kit 6 (JDK 6) -:按我到下载网址
***注意,一定要先装JDK先,不然你的IDE不会detect到你的IDE。




2.Integrated development environment(IDE)-你编码用的软件,我建议用TextPad。
请到http://www.textpad.com/download/index.html下载TextPad。


先写到这么多,下篇会教你们写你们编写的第一个程序。如果有什么问题请你留言,我会尽力帮助你。

大家来学programming


昨天喝茶,我问我的朋友,想学programming吗?他们都说想。其实我之前也想和大家分享我学到的programming的知识,但是迟迟没动手把东西写进blog。所以趁这几天有写blog的mood时,开始写一些关于programming的文章。

Programming是一个牵涉到设计,写程序,测试/debugging等等。我会专注在coding这方面,也就是编码。

其实我们所用的电脑程序(软件)是一组由一个CPU序列执行指令。简单来说,就是一组命令去让我们的CPU执行一些任务。

学会编码有什么好处?当你学会编码后,你能重写我们的operating system(这当然不容易,除非你有很大的编码天分),你可以写一些实用的小工具,如简单的计算机软件,小游戏等等。举个例子说,你在工作时,你常用到一个计算方程式,而你都是利用计算机和人手来计算,如果你用编码的知识来写一个小软件,你只需输入需要的资料,按一按“计算”就可以了。




软件可以由以下这些编程语言写成:
  • 低阶语言(Low-level language):组合语言,为硬体间各装置沟通的桥梁软件,又称为韧体(例如BIOS)。
  • 高阶语言(High-level language):Basic、C语言、C++语言……等,为编辑作业系统和应用软件的语言。
  • 脚本语言(Scripting language):例如Shell Script、Javascript、PHP、Python。
如果你们想了解它们有什么分别,可以去Google搜查。

我想和大家分享的编码语言是JAVA。这个由 James Gosling研发的编码语言在程序界有举足轻重的地位。他有着简单和高流动性(用Java写的程序能在不懂的作业系统上运作)的特点。而且他的syntax比较”人性“化,比较容易记。

如果你不明白我上面所写的东西,没关系,你可以在Google搜查"programming"来了解更多。

我会在下一篇文章开始写相关的资料。
_________________________________________________________________
以下为市场资讯,点击以获得更多详情,谢谢^.^

LinkWithin

Related Posts with Thumbnails