i am beginer in windows base aplication so i dont know how to make connectivity in windows appliction using any datasource so plz help me out.....

hi rutul,

there are 2 things

1)
first of all u shud create a connection string
refer this site it has for all types of databases.

2)
and then execute an sql command

here is a sample program to connect to an sql server 2005 with C#(its compiled inVS2003)

it continously reads from a text files & writes line by line into the database----

using System;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Odbc;
using System.Data.Common;
using System.Data;
using System.IO;


namespace db
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///


class Class1
{


static int i=1;
static string ss=null;
static string t="IOI";
static string str=null;
static SqlCommand thisCommand;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(@"Integrated Security=SSPI;Initial Catalog=sec;Workstation ID=3035-HEADSTRONG;");
thisConnection.Open();
StreamReader sr= new StreamReader(@"e:\fast.txt");
str="insert into fix(msg,id,type) values(@msg,@id,@type)";
ss=sr.ReadLine();
while(ss!=null)
{
i++;
thisCommand= new SqlCommand(str,thisConnection);
thisCommand.Parameters.Add("@msg",ss);
thisCommand.Parameters.Add("@id",i);
thisCommand.Parameters.Add("@type",t);
thisCommand.ExecuteNonQuery();
ss=sr.ReadLine();
}
thisCommand.CommandText="select * from fix";
SqlDataReader sdr = thisCommand.ExecuteReader();
while (sdr.Read())
{
Console.WriteLine("\t{0}\t{1}", sdr["msg"], sdr["id"]);
Console.WriteLine();
}
sdr.Close();
}


}
}

if u hv furthur doubts, let me know

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.