Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Friday, January 7, 2011

How to call SP ( stored procedure ) in c# ?

SqlConnection conn=new SqlConnection("connection string here");

     SqlCommand cmd=new SqlCommand();
    
     cmd.Connection = conn;
     cmd.CommandText = "StoredProcedure_Name_here";
     cmd.CommandType = CommandType.StoredProcedure;
     SqlDataAdapter DataAdapterHome = new SqlDataAdapter(cmd);
     DataSet ds= new DataSet();
    
      DataAdapterHome.Fill (ds);

How to ping In vb.net

here i will show how you can ping another computer in Vb.net

 

here is the code for ping command.

You can pass Ip or address to argument of Ping function:

If host is available and successfully pings the it show messsge Pinging Successful else Host is not available
and if host is not found, then it will throws an exception.

             Dim RESPONSE As Boolean = My.Computer.Network.Ping("www.eggheadcafe.com")
            If RESPONSE = True Then
                 MsgBox("Pinging Successful")
            Else
                 MsgBox("Host is not available ")
            End If
 

How to open a webpage in current browser

Here i will show how you can open a webpage in a defualt browser.

 

 string url = "url from user";
           
            // check http included or not
            if (!url.ToLower().StartsWith("http://"))
            {
                 // if not the add http
                url = "http://" + url;
             }
             // it will open a url in current default browser
           System.Diagnostics.Process.Start(url);

How to use InputBox in c#

Here i will show how you can make use of InputBox in c#. There is no control for InputBox in c# but you can get that from VisualBasic.

 

First you have to add one .dll file from the

Project
Menu -> Add refercenc - > Micorsoft.VisualBasic

and then you can make use of InputBox.

            String yourname = Microsoft.VisualBasic.Interaction.InputBox("Enter Your Name");
             MessageBox.Show("Your name is :" + yourname);

 

 

How to use InputBox in c#

Here i will show how you can make use of InputBox in c#. There is no control for InputBox in c# but you can get that from VisualBasic.

 

First you have to add one .dll file from the

Project Menu -> Add refercenc - > Micorsoft.VisualBasic

and then you can make use of InputBox.

            String yourname = Microsoft.VisualBasic.Interaction.InputBox("Enter Your Name");

             MessageBox.Show("Your name is :" + yourname);