ujwaliyer 0 Newbie Poster

i dont think u need anything more......

1) include the reference
2) put it in the using clause

try creating a whole new project with only that ref included

& then try using it.

ujwaliyer 0 Newbie Poster

google it...


u'll get loads of it.

see

csharpfriends.com

aspfree.com

csharpcorner

ujwaliyer 0 Newbie Poster

-post is a bit unclear man....


wats d code... it';ll b better to solve

ujwaliyer 0 Newbie Poster

try including it i the references.....

let me know

ujwaliyer 0 Newbie Poster

post is unclear......

exp in detail wat d problem is

let me know

ujwaliyer 0 Newbie Poster

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

ujwaliyer 0 Newbie Poster

mail if anybody has doubt inC#-- iyerujwal@gmail.com

ujwaliyer 0 Newbie Poster

i got it...

here's the code

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();
        }

    }
}
ujwaliyer 0 Newbie Poster

go to the design view, select the button

and go to the properties - then change the name of the button..

ujwaliyer 0 Newbie Poster

you can use SQL server.

if u have any queries let me know

ujwaliyer 0 Newbie Poster

i tried both of your suggestions but i am getting the same exception again---

Unhandled Exception: System.IndexOutOfRangeException: An SqlParameter with ParameterName 'msg' is not contained by this SqlParameterCollection.

i have checked the table- both the names of the parameters are right.

ujwaliyer 0 Newbie Poster

i want to insert rows one by one into a database in the sql server 2005.

the problem is that i have tried all possible but the rows just dont get added to the database, i get an exception

on executing this code, i get this exception

Unhandled Exception: System.IndexOutOfRangeException: An SqlParameter with ParameterName 'msg' is not contained by this SqlParameterCollection.

here is the code -

SqlConnection thisConnection = new SqlConnection(@"Integrated Security=SSPI;Initial Catalog=sec;Workstation ID=3035-HEADSTRONG;");
thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
StreamReader sr= new StreamReader(@"e:\fast.txt");
string ss=null;
int i=1;
ss=sr.ReadLine();
Console.WriteLine(ss);
    while(ss!=null)
        {
        i++;
        thisCommand.Parameters["msg"].Value=ss;
        thisCommand.Parameters["id"].Value=i;
        // -----------i have tried this too--------
                //thisCommand.CommandText = "INSERT INTO fix (msg,id) VALUES (ss,i)";
        //thisCommand.ExecuteNonQuery();
        ss=sr.ReadLine();

    }
ujwaliyer 0 Newbie Poster

>am not able to install the service , an exception gets raised
What exception?

hi narue,
thanks for taking time for my problem
it says that the operation "did not complete in a timely fashion"

furthurmore- the windows marks my service for "deletion".
so i am not able to use it anymore...

ujwaliyer 0 Newbie Poster

hello everyone,

I have created a console app for receiving files thru sockets.

Now what i need to do is to change it to a windows service so that it will dynamically keep receiving files all the times -- and store them in a separate folder.

The problem is that-

1) am not able to install the service , an exception gets raised. As a result "the windows marks my service for deletion."

here is the code-

private static int localPort = 6000 ;
	private static UdpClient receivingUdpClient = new UdpClient(localPort);
	private static IPEndPoint RemoteIpEndPoint = null ;
	private static FileStream fs;
	private static byte[] receiveBytes = new byte[0]; 
		
		
	public static void ReceiveFile()

	{
			try
			{
				
	// Receive file
	receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);	i++;
	fs = new FileStream(@"E:\recd files\temp"+i+"."+"txt", FileMode.Create,
	FileAccess.ReadWrite, FileShare.ReadWrite);
	fs.Write(receiveBytes, 0, receiveBytes.Length);
	Process.Start(fs.Name);
			}
			catch (Exception e)
			{
				//Console.WriteLine(e.ToString ());
			}
			finally
			{
				fs.Close();
			}
		}
        
protected override void OnStart(string[] args)
{
			
     ReceiveFile();
				
}

any help would be highly appreciated