Monday, March 26, 2012

JDBC Transactions

Most of the times transactions are important when we deal with JDBC. When we perform database operations if we don't realize the importance of transactions it will end up with a tragedy. I have created a scenario to demonstrate the importance of a transaction.
Scenario :
Lets assume a scenario where a transaction credit 500 rs from user1 and debit that 500 rs to user2 .

initial state of accounts

Thursday, March 22, 2012

Friday, February 10, 2012

How to Implement Threaded Server Socket Application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.Threading;
namespace ServerSocketApp

Saturday, February 4, 2012

Arrays in .NET Webservices

Web Service
public class Service1 : System.Web.Services.WebService
{
 [WebMethod]
 public int[] sort(int[] arr)
 {
  Array.Sort(arr);
  return arr;
 }
}
Then run the service.
Copy the URL of the WSDL
ex :  http://localhost:4886/Service1.asmx?WSDL

Reading Text from Files (C#.net)

private void button2_Click(object sender, EventArgs e)
{
try
{
 string buffer;
 StringBuilder stb = new StringBuilder();
 StreamReader strmRdr = File.OpenText("c:\\testfile.txt");
 while ((buffer = strmRdr.ReadLine()) != null)
 {
  stb.Append(buffer);
  stb.Append(Environment.NewLine);

Writing Text to files( C#.net )

private void button1_Click(object sender, EventArgs e)
{
 try
 {
  FileStream fileStrm = File.Open("c:\\testfile.txt", FileMode.OpenOrCreate);
  StreamWriter writer = new StreamWriter(fileStrm);
  writer.WriteLine("First Line");
  for (int i = 2; i < 100; i++)
  {
   writer.WriteLine("This is line {0}", i);

Friday, February 3, 2012

Using DataGridView to Show Data in a table

Selecting multiple files and show their information on a DataGridView
    public partial class Form1 : Form
    {
        private String[] selectedFiles;
        public Form1()
        {
            InitializeComponent();
        }

Using FileOpen Dialog

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open a file to process";
            //selectable file types
            openFileDialog1.Filter = "Portable Document Format (*.pdf)|*.pdf|Text Documents(*.txt)|*.txt";
            openFileDialog1.InitialDirectory = "c:\";
            DialogResult respo= openFileDialog1.ShowDialog();
            if (respo == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
            else
            {
                textBox1.Text = "No selected file!";
            }
        }

Thursday, February 2, 2012

Progressbar Update In C#.net

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace ThreaddedApp
{
    public partial class Form1 : Form
    {
        delegate void progressbarrunnerDelegate();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Invoke(new progressbarrunnerDelegate(progressbarrunner));
        }

        private void progressbarrunner()
        {
            for (int i = 0; i < 100; i++)
            {
                Thread.Sleep(50);
                this.progressBar1.Value = i;
                Application.DoEvents();
            }
        }
    }
}

Monday, January 23, 2012

Using GET and POST methods in J2ME

Most of the mobile applications are not alone. They frequently communicate with web services or web applications to accomplish their tasks. Lets see how to make GET and POST requests to a server.
We can use HttpConnection class to make requests.
Lets see what are the basic steps.
© kani.stack.notez 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis