Here you go

Tuesday, May 12, 2009

Using Configuration Files (App.config) in C# and VB.Net

firstly you shuold know about application files.

APP.config files

Configurations files make your life easier.
In an APP.config file, information is stored as Key-Value pairs.
Each application can have a configuration file, which is actually an XML file.
Any text editor can be used to open the configuration file and change values.
The application will load the values from this configuration file.
App.Config files are not even use for connection string, they have several other benifits.
  • If you need to change the server then you will have to change the connection string as well. So,there is no need change your code.
  • You just simply change or replace the connection string in (App.Config) Configuration file.Or replace whole Configuration file.
  • The configuration file for VB.Net or C#.Net will remain same.

Now do it practically:

  • App.config files are not automatically created when you create a Windows application.
  • If you need aconfiguration file for your application, open your project in VS.NET, go to the 'Solution Explorer' and right click on the project name. Choose Add -> Add new item from the menu and select 'Application Configuration file' from the list of choices. This will create an app.config file for you in the application root.
  • Open app.config file then replace all its code by the following code (donot leave a line or white space).







server = server name ; uid = user id of your database ; pwd = password of your database
databae = name of your database



Now you can code your Form like :( in C#.net)

Open your form drag a Button on your form and named it btnConnect.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Configuration; //Must add this name space (system.Configuration)
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ConnectionString
{
public partial class Form1 : Form
{
// this line communicate with App.Config File

string dbPath = ConfigurationSettings.AppSettings["DatabasePath"];

// your query
string query = "SELECT * FROM Registration;";

SqlDataAdapter sqlDA;
DataSet dS;

public Form1()
{
InitializeComponent();
}



private void btnConnect_Click(object sender, EventArgs e)
{
//filling dataset

try
{

dS = new DataSet();
SqlConnection sqlCon = new SqlConnection(dbPath);
SqlCommand sqlComm = new SqlCommand(query, sqlCon);
sqlDA = new SqlDataAdapter(sqlComm);
sqlDA.Fill(dS, "table1");
MessageBox.Show("Data has been Filled in Dataset");
}

//If error Occur in filling DataSet then this code will be executed

catch (Exception ex)
{
MessageBox.Show("Error Occured" + ex.Message);
}

}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}






Monday, May 4, 2009

Convert code VB to C# or C# to VB


Free Code Conversion:


Using this Site you can Convert Your Code From several languages to Others. ( Free of Cost )

http://www.developerfusion.com/tools/convert/csharp-to-vb/


Key Words:

C# to VB

C#.Net to VB.Net

Convert C Sharp to VB

Dot Net Code Conversion

Convert Code 

Convert VB to C#

Dot Net Code Converter 

Saturday, April 18, 2009

What are Tables? How to make Table?

What are Tables?
  • Tables are the basic structure where data is stored in the database.
  • Tables are divided into rows and columns.
  • Each row represents one piece of data.
  • Each column can be thought of as representing a component of that piece of data.
  • For example: If we have a table for recording customer information, then the columns may include information such as First Name, Last Name, Address, City, Country, Birth Date, and so on. As a result, when we specify a table, we include the column headers and the data types for that particular column.
So what are data types?
  • Typically, data comes in a variety of forms.
  • It could be an integer such as 1, 2, 1002, -2002 etc.
  • It could be real number. The real numbers include both rational numbers, such as 42 and −23/129, and irrational numbers, such as pi and the square root of two
  • It could be a string such as 'sql', 'my name is burhan'
  • It could be a date/time expression such as '2000-JAN-25 03:22:22'
  • It coold be in binary format.
Note:
  • When we specify a table, we need to specify the data type associated with each column. For example we will specify that 'First Name' (the column of any table) is of type char(50) - meaning it is a string with 50 characters).
  • Many database tools allow you to create tables without writing SQL, but given that tables are the container of all the data.
  • SQL is a standard language for accessing and manipulating databases.
  • You can use SQL to access and manipulate data in MySQL, SQL Server, MS Access, Oracle, Sybase, DB2, and other database systems.
How to make Table?
A table is look like:

P_Id
LastName
FirstName
Address
City
1
Hansen
Ola
Timoteivn 10
Sandnes
2
Svendson
Tove
Borgvn 23
Sandnes
3
Pettersen
Kari
Storgt 20
Stavanger

The table above contains three records (one for each person) and five columns (P_Id, LastName, FirstName, Address, and City).

So, if we are to create the customer table specified which have First Name, Last Name, Address, City, Country, Birth Date. So we would type in:

CREATE TABLE customer (First_Name char(50),Last_Name char(50), Address char(50), City char(50), Country char(25), Birth_Date date);

here:
* "customer" is table name.
* "CREATE TABLE" is a key word use to make a new table.
  • Sometimes, we want to provide a default value for each column.
  • A default value is used when you do not specify a column's value when inserting data into the table.
  • To specify a default value, add "Default [value]" after the data type declaration.
  • In the above example, if we want to default column "Address" to "Unknown" and City to "Karachi", we would type:

CREATE TABLE customer (First_Name char(50), Last_Name char(50), Address char(50) default 'Unknown', City char(50) default 'Mumbai', Country char(25), Birth_Date date);



.NET Framework Deep Overview


The .NET Framework is Microsoft's platform for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. By providing you with a comprehensive and consistent programming model and a common set of APIs, the .NET Framework helps you to build applications that work the way you want, in the programming language you prefer, across software, services, and devices.
Secure, Multi-Language Development Platform. Developers and IT professionals can count on .NET as a powerful and robust software development technology that provides the security advancements, management tools, and updates you need to build, test, and deploy highly reliable and secure software. .NET supports the programming language you prefer by providing one multi-language development platform, so you can choose how you want to work. The Common Language Runtime (CLR) provides support for powerful, static languages like Visual Basic© and Visual C#©, and the advent of the Dynamic Language Runtime (DLR) means that dynamic languages, such as Managed Jscript, IronRuby and IronPython, are also supported.
Rapid, Model-Driven Development Paradigm. .NET offers pioneering solutions that enable rapid application development and result in dramatic increases in productivity. For example, the new ADO.NET Entity Framework offers a model-based development paradigm and a standards-based framework that raises the level of abstraction for database programming, allowing developers to cleanly separate one's business logic, data and user interface. By programming against a conceptual application model instead of programming directly against a relational storage schema, developers can greatly reduce the amount of code and maintenance required for data-oriented applications.
Next-Generation User Experiences. Windows Presentation Foundation (WPF) provides a unified framework for building applications and high-fidelity experiences in Windows Vista that blend together application UI, documents, and media content, while exploiting the full power of the computer. WPF offers developers support for both 2D and 3D graphics, hardware accelerated effects, scalability to different form factors, interactive data visualization, and superior content readability. Further, with a common file format (XAML), designers can become an integral part of the development process by working alongside developers in a workflow that promotes creativity while maintaining full fidelity.
Cutting-Edge Web Application Development. ASP.NET is a free technology that enables Web developers to create anything from small, personal Web sites through to large, enterprise-class dynamic Web applications. Microsoft's free AJAX (Asynchronous JavaScript and XML) framework – ASP.NET AJAX – enables developers to quickly create more efficient, more interactive, and highly personalized Web experiences that work across all of the most popular browsers. And the new ASP.NET Dynamic Data functionality in Visual Studio 2008 uses a rich scaffolding framework that allows rapid data-driven Web development without writing any code.
Secure, Reliable Web Services. The service-oriented programming model of Windows Communication Foundation (WCF) is built on the Microsoft .NET Framework and simplifies development of connected systems and ensures interoperability. Windows Communication Foundation unifies a broad array of distributed systems capabilities in a composable and extensible architecture, spanning transports, security systems, messaging patterns, encodings, network topologies, and hosting models.
Enabling Mission-Critical Business Processes. With .NET, developers can use Windows Workflow Foundation (WF) to model a business process with code, enabling closer collaboration between developers and business process owners, and providing end users with better access to data, thereby improving productivity.
Superior Reach Across Devices and Platforms. The .NET Framework enables developers to build solutions for a wide array of devices, from personal computers and servers to mobile phones and embedded devices. Silverlight, a runtime that contains a subset of the .NET Framework, helps developers expand their reach by providing a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET-based media experiences, advertising and rich interactive applications (RIAs).
For an a deeper, conceptual overview of the .NET Framework, please click here

What is .Net?

The .NET Framework is Microsoft's comprehensive and consistent programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.