Thêm số thứ tự trong TDBGrid

Đôi khi chúng ta muốn thể hiện số thứ tự của các dòng trên TDBGrid, tuy nhiên hiện tại TDBGrid trên tất cả các phiên bản của Delphi chưa cho phép chúng ta thực hiện điều này.

Chúng ta có thể thực hiện việc vẽ riêng Column này trên DBGrid bằng tay

Trên DBGrid thêm một có Caption là STT

Tiếp theo trong Event DrawColumnCell thêm dòng

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;   DataCol: Integer; Column: TColumn; State: TGridDrawState);

begin   if DataSource1.DataSet.RecNo > 0 then

begin     if Column.Title.Caption = ‘STT’ then

DBGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top, IntToStr(DataSource1.DataSet.RecNo));

end;

end;

 

Và kết quả như sau:

Chúc các bạn thành công 🙂

Thiết lập cấu hình cho phép truy cập SQL Server từ máy trạm

Khi cài đặt Microsoft SQL server chúng ta không thể kết nối với database từ máy trạm. Để cho phép việc truy xuất từ máy trạm chúng ta sử dụng công cụ SQL Server Configuration Manager

Chọn “SQL Server Network Configuration”

Double Click vào TCP/IP và Named Pipes sau đó Enable hai dịch vụ này

Sau khi cấu hình hoàn tất, restart lại Database

Thiết lập cấu hình mạng trong VMWare Player

Như chúng ta đã biết hãng VMWARE đã cung cấp cho chúng ta một công cụ tuyệt vời để giải quyết vấn đề bản quyền của hệ điều hành và ứng dụng. Tuy nhiên VMware player (miễn phí) chỉ cung cấp cho chúng ta một số công cụ quản trị đơn giản, một vấn đề nảy sinh là khi dùng VMware player các bạn không thể nào cấu hình NAT… cho máy ảo sử dụng. Nhưng may thay một số thành viên đã giải quyết vấn đề này. Tôi xin trích nguyên văn đoạn blog dưới đây, nếu bạn gặp vấn đề tương tự thì có cách giải quyết.

I updated VMware Player to the latest version (3.0) on my home machine last night[1]. Wanted to check out the latest version and get a first hand look at the new features.

I pointed it to my trusty Xubuntu “security” virtual machine and booted up. I ran into a snag pretty quickly though. Seemed that the client couldn’t get an IP address to get on the network.

I’ve seen and fixed this before. VMware Player seems to like to grab my Hamachi “personal VPN” network adapters instead of the local Ethernet one – it will never get an IP from the Hamachi network!

That’s when I hit the next snag: the new version of VMware Player doesn’t include the vmnetcfg network configuration that I’ve always used to fix this in the past. I poked around a bit but it wasn’t there and I didn’t see anything that looked like a replacement.

I ended up fixing this in a bit more of a low-tech fashion. I simply disabled the Hamachi adapter and then booted the VMware client. Client got an IP and I then re-enabled the Hamachi adapter.

Disabling a network adapter

Of course, after my low-tech solution I went looking for better options… Turns out I’m not the first one to notice that vmnetcfg went missing. I found discussion and the answer.

The vmnetcfg.exe is included in the installer, but won’t be installed.
1. Run the installer with /e option. For example:
VMware-player-3.0.0-197124.exe /e .\extract
All contents will be extracted to “extract” folder.
2. Open “network.cab” and copy vmnetcfg.exe to your installation folder,
typically “C:\Program Files\VMware\VMware Player\”.

 

Nguồn http://www.solo-technology.com/blog/2009/10/29/vmware-player-3-0-and-network-configuration/

Lazarus và công nghệ phát triển ứng dụng cho nhiều hệ điều hành đựa trên Freepascal

 

Như chúng ta đã biết công nghệ phát triển ứng dụng trên nền Windows 32 rất nhiều và rất mạnh. Trong số tứ đại thiên vương hiện nay không thể nào không nhắc đến Delphi do Borland khởi xướng.

Từ những phiên bản đầu tiên, borland đã cung cấp cho giới phát triển ứng dụng bộ thư viện lập trình đồ sộ, thích hợp cho nhiều loại dự án khác nhau, từ đơn giản đến phức tạp, lập trình hệ thống, lập trình CSDL… Tuy Borland đã hỗ trợ thư viện lập trình khác ngoài hệ điều hành Windows như kylix. Tuy nhiên Kylix rất ít được giới lập trình viên quan tâm và dần đi vào quên lãng.

Một số Fan cuồn nhiệt của ngôn ngữ lập trình Pascal đã không chịu bó tay và họ đã phát triền nên Lazarus. Lazarus là trình IDE cho Freepascal trên mọi nền tảng(MacOS, Windows, Linux….). Đây có lẽ là bước tiến dài và vững chắc cho giới lập trình Pascal.

Sau đây các bạn có thể cùng tôi khám phá ngôn ngữ Pascal qua công cụ lập trình Lazarus hấp dẫn này nhé.

  1. Trang chủ của Lazarus, nơi bạn có thể tìm bất kỳ tài liệu hướng dẫn cũng như cách xử lý tình huống với Lazarus và Freepascal.
  2. Download Lazarus và trình biên dịch freepascal.
  3. Cài đặt Lazarus và khám phá, có thể nói Lazarus gần như giống 90% với Delphi 7.

Embarcadero giới thiệu Dephi XE cho Windows

Đầu tháng vừa qua Embarcadero đã cho ra mắt bộ công cụ lập trình mới cho Pascal là Rad Studio XE. Bộ công cụ này bao gồm :

  • Delphi XE : Lập trình ngôn ngữ Delphi trên nền Windows 32.
  • Delphi for .Net  : Đây là bộ công cụ chạy độc lập hay có thể tích hợp với trình IDE của Microsoft, tận dụng ưu thế của nền .Net Framework và khả năng xử lý nhanh của ngôn ngữ Pascal.
  • Delphi for PHP.
  • C++ Builder

Bạn có thể Download bản dùng thử tại đây

Lưu ý :  Nếu bạn đã cài bộ RAD 2009 rồi thì khi cài RAD XE này vào có nguy cơ mất bản quyền (đã crack Nụ cười) trước đó. Sau đây là một số hình ảnh của bộ RAD XE.

New Delphi XE and C++Builder XE with an expanded developer toolbox, cloud and multi-tier New RadPHP added to RAD Studio for Web and Facebook app development rad2010_thumb3
Hỗ trợ công nghệ ảo hóa của Microsoft Lập trình Web với PHP trên RAD XE Lập trình Pascal và .NET

PostgreSQL đã có phiên bản 9.0 hỗ trợ nền tảng Windows 64bit

PostgreSQL 9.0 Final Release Available Now!

Posted on 2010-09-20
Posted by press@postgresql.org

PostgreSQL 9.0 is here! The PostgreSQL Global Development Group announces the availability of our most eagerly awaited release. PostgreSQL 9.0 includes built-in, binary replication, and over a dozen other major features which will appeal to everyone from web developers to database hackers.

9.0 includes more major features than any release before it, including:

  • Hot standby
  • Streaming replication
  • In-place upgrades
  • 64-bit Windows builds
  • Easy mass permissions management
  • Anonymous blocks and named parameter calls for stored procedures
  • New windowing functions and ordered aggregates

… and many more. For details on the over 200 additions and improvements in this version, developed by over a hundred contributors, please see the release notes.

“These kinds of feature additions continue to make a strong case for why mission-critical technology tasks can continue to depend on the power, flexibility and robustness of PostgreSQL,” said Afilias CTO Ram Mohan.

 

Phiên bản mới nhất của InterBase Database phát hành.

New InterBase XE from Embarcadero: Embed. Deploy. Relax.

Features such as a lightweight footprint and near-zero administration continue to make InterBase® XE ideal for all embedded applications. InterBase has already been proven in thousands of embedded applications such as retail point-of-sale systems and CRM solutions.

InterBase XE combines a multi-version architecture with simple installation, minimal administration. The new XE edition can now handle eight times more data and offers more security options. InterBase XE, a full-featured, relational database management system (RDBMS) is designed for developers to create resilient business-critical applications for embedding in devices, appliances and small enterprise, desktop and workgroup solutions.

Additional new features now available with InterBase XE include:
* Cloud Deployment
– Cloud deployment of InterBase XE allows developers to rapidly provision
systems and expand and contract capacity as business demands
* Improved Productivity
– Improves developer productivity by allowing Dynamic SQL to be called
from Stored Procedures and Triggers
* Handles More Data
– InterBase XE’s 64-bit architecture can address more memory and handle
larger tables for improved scalability
* Enhanced Support
– InterBase XE includes support for JDBC BLOB/CLOB

InterBase XE can be deployed on a wide variety of platforms including Windows, Mac OS X, Linux and now, the Amazon Cloud.

+++++++++++++++++++++++++++++
Pricing and Availability

InterBase XE is available in four editions to meet a wide variety of processing requirements:

InterBase XE Server Edition is suitable for multi-tier applications that can scale up to 64processors.

InterBase XE Desktop Edition provides a cost-effective, high performance repository for single-user applications.

InterBase XE To Go Edition provides ultra-light weight, in-process DBMS capabilities perfect for embedded in today’s new portable devices.

FREE InterBase XE Developer Edition is now included in RAD Studio XE that also includes Delphi XE, C++Builder XE, Delphi Prism XE and RadPHP XE.
Available here for download: https://downloads.embarcadero.com/free/interbase

To learn more, visit  http://www.embarcadero.com/products/interbase

For your nearest reseller or Embarcadero sales office please visit http://www.embarcadero.com/company/contact-sales-or-find-partner

Danh mục website thư viện mã nguồn và lập trình Pascal/Delphi

  1. http://www.delphibasics.co.uk/ -> web site học lập trình Delphi căn bản và dễ hiểu nhất.
  2. http://delphi.about.com
  3. http://www.delphifans.com/ (chú ý website tiếng Trung Quốc)
  4. http://www.embarcadero.com/ -> Website chính thức của hãng Borland trước kia
  5. http://symmetrica.net/newac/ -> Bộ component trùm cho lập trình xử lý audio (Open source).
  6. http://www.delphipages.com/ -> Forum delphi
  7. http://www.torry.net/ -> Chuyên Component, Freeware, Shareware, Licences….
  8. www.devexpress.com/ -> Trùm component của Delphi, Borland C, .NET
  9. http://www.componentone.com/ -> Chuyên component cho Delphi và .NET
  10. http://www.indyproject.org/index.en.aspx -> Bộ component miễn phí và rất mạnh mẽ trong việc lập trình mạng (TCP/IP, UDP, Pop3, ….)

Tạo file xem cấu hình hệ điều hành Windows

Tạo file xem cấu hình hệ điều hành Windows

Đôi lúc chúng ta cần xem cấu hình phần mềm cũng như phần cứng của hệ điều hành Windows mà chúng ta đang xài một cách tổng quan và đầy đủ nhất. Ngoài một số công cụ của các hãng thứ ba phát triển để hỗ trợ việc này. Tuy nhiên tôi xin giới thiệu một thủ thuật nhỏ để xem và tìm tất cả mọi thông tin của hệ thống mà không cần bất cứ công cụ nào.

Tạo một tập tin bất kỳ có đuôi mở rộng là .txt, hoặc ….. bất kỳ

Đổi tên tập tin này thành xxxx.nfo

vậy là chúng ta có file xem cấu hình toàn hệ thống.

Backup và Restore database sql server

Backup và Restore database sql server, dùng công cụ “Enterprise Management…”

Đăng nhập vào SQL Server bằng công cụ  SQL Management

Chú ý tài khoản đăng nhập phải là SA hoặc tài khoản có quyền Backup Database

Chọn nơi lưu trữ file backup

Nhấn OK để thực hiện Backup

C# và Postgres SQL database

Hiện nay công nghệ .NET hầu như đã cung cấp cho chúng ta nhiều driver để kết nối đến nhiều loại Database khác nhau, từ Oracle, SQL Server, Access… Trong số đó có một Hệ quản trị CSDL mã nguồn mở và được sử dụng khá nhiều nhưng .NET quên support đó là Postgres SQL Database. May thay đã có cộng đồng mã nguồn mở phát triển driver và hỗ trợ
1 – Trước tiên download Postgres Database tại đây :
2 – Download database Driver tại đây
3 – Sau khi xả nén thư viện NPSQL chúng ta sẽ thấy tập tin “Npgsql.dll”
4 – Tạo project mới trên VS2k5, VS2k8, VS2010
add reference “Npgsql.dl” vào project
và thêm vài thao tác cơ bản như làm việc trên MSSQL server
using Npgsql;
NpgsqlConnection con;
string connectionString =
“Server=localhost;” +
“Database=northwind;” +
“User ID=postgres;” +
“Password=yourpassword”;
private void button1_Click(object sender, EventArgs e)
{
con = new NpgsqlConnection(connectionString);
try
{
con.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
NpgsqlDataAdapter da = new NpgsqlDataAdapter();
NpgsqlCommand cmd = new NpgsqlCommand(“select * from table_name”);
da.SelectCommand = cmd;
cmd.Connection = con;
DataSet ds = new DataSet();
da.Fill(ds, “table”);
dataGridView1.DataSource = ds.Tables[0];
}

Hiện nay công nghệ .NET hầu như đã cung cấp cho chúng ta nhiều driver để kết nối đến nhiều loại Database khác nhau, từ Oracle, SQL Server, Access… Trong số đó có một Hệ quản trị CSDL mã nguồn mở và được sử dụng khá nhiều nhưng .NET quên support đó là Postgres SQL Database. May thay đã có cộng đồng mã nguồn mở phát triển driver và hỗ trợ
http://npgsql.projects.postgresql.org/index.html
1 – Trước tiên download Postgres Database tại đây :  http://www.enterprisedb.com/products/pgdownload.do#windows
2 – Download database Driver tại đây   http://pgfoundry.org/frs/?group_id=1000140
3 – Sau khi xả nén thư viện NPSQL chúng ta sẽ thấy tập tin “Npgsql.dll”
4 – Tạo project mới trên VS2k5, VS2k8, VS2010   add reference “Npgsql.dl” vào project
và thêm vài thao tác cơ bản như làm việc trên MSSQL server
using Npgsql;      NpgsqlConnection con;        string connectionString =            “Server=localhost;” +            “Database=northwind;” +            “User ID=postgres;” +            “Password=yourpassword”;        private void button1_Click(object sender, EventArgs e)        {            con = new NpgsqlConnection(connectionString);            try            {                con.Open();            }            catch (Exception ex)            {                MessageBox.Show(ex.Message);            }        }
private void button2_Click(object sender, EventArgs e)        {            NpgsqlDataAdapter da = new NpgsqlDataAdapter();            NpgsqlCommand cmd = new NpgsqlCommand(“select * from table_name”);             da.SelectCommand = cmd;            cmd.Connection = con;            DataSet ds = new DataSet();             da.Fill(ds, “table”);            dataGridView1.DataSource = ds.Tables[0];        }

Giới thiệu lập trình Delphi

Trong bài viết này tôi xin giới thiệu về lập trình Delphi mà tiền thân của nó là Pascal, những thuận lợi và khó khăn trong việc học và làm trên ngôn ngữ này.

Trong bài viết này tôi xin giới thiệu về lập trình Delphi mà tiền thân của nó là Pascal, những thuận lợi và khó khăn trong việc học và làm trên ngôn ngữ này.

Bỏ xác nhận mật khẩu khi chia sẻ thư mục trong Windows7

Trong Windows7 đôi khi chúng ta chia sẻ một thư mục cho mọi người nhưng vẫn nhắc đăng nhập User Name và Password.
Sau đây tôi xin hướng dẫn bỏ việc nhắc Tên đăng nhập và mật khẩu khi chia sẻ một thư mục :