Posts Tagged ‘c’

Oracle : Connection String For Oracle Database using C#

September 2nd, 2013, posted in Oracle, Programming
Share

Connection String For Oracle Database using C# ,Connection String For Oracle Database, using C# ,Connection String ,Oracle Database,C# ,Oracle Database,progamming

Sometimes we learn a lot of things after a hard struggle then after a period of time we forget the process or something which is a key and after that we spent time to get the solution again. A documentation of each activity might help to make your portfolio that’s why I am writing a blog because it’s a better idea “what you learn write ones”  So, Today I am going to explain you Connection String C# to Oracle Database.  Occasionally we have seen C# to Sql Server in many other blogs and Microsoft web sites. C# to Oracle connection string is Similar to C# to SQL Server Connection String with one additional step Here we go :

Step# 1
Open Visual Studio 2010 [ I am assumed that you are using VS2010 ] , Click on File->New->Website Then select from the left pane Visual C# and then select ASP.net Web Site. Note: .Net Framework 4 should be selected.

Step#2

Right click on the project for ” add new Item” click ok

Step#3
Open “Default.aspx.cs” file or whatever your file name with the extension “aspx.cs”  from the solution Explorer [ Ctrl + Alt + L ]

Step# 4
Again Right click on the project and “Add ASP.Net Folder“ then select “Bin“.  Download the file ” System.Data.OracleClient.dll ”  from:  http://www.dllme.com/dll/files/system_data_oracleclient_dll.html and then place in the Bin folder which you have created then refresh the project folder from the VS2010

Step# 5

Now add this in to header of Default.aspx.cs file
using System.Data.OracleClient; using System.Data; using System.Configuration;

Step# 6
Open web.config and add this under connectionStrings tag <add name=”TestConn” connectionString=”Data Source=TestSource; User;password=Test;Persist Security Info=False” providerName=”System.Data.OracleClient”/> Save file with your credentials and close

Step# 7

Now back to the default.aspx.cs
public void muFunc()
{
string arr;
string connStr = System.Configuration.ConfigurationManager.ConnectionStrings[“TestConn”].ConnectionString;

try
{
OracleConnection conn = new OracleConnection(connStr);
string query = “SELECT * FROM Orders”;
conn.Open();

}
catch (Exception Er)
{

}
finally
{
Conn.Close();
}
}
Hope this helps to you.

Note : This blog was written by a friend.
http://fahadshamsi.blogspot.com/2013/01/CsharptoOracleConnection.html

Share

C Program To Shutdown Or Turn Off Computer

February 20th, 2013, posted in C
Share

To shutdown immediately use “C:\WINDOWS\System32\ shutdown /s /t 0”. To restart use /r instead of /s.

C Program to shutdown your computer: This program turn off i.e shutdown your computer system. Firstly it will asks you to shutdown your computer if you press ‘y’ the your computer will shutdown in 30 seconds, system function of “stdlib.h” is used to run an executable file shutdown.exe which is present in C:WINDOWSsystem32 in Windows XP. You can use various options while executing shutdown.exe for example -s option shutdown the computer after 30 seconds, if you wish to shutdown immediately then you can write “shutdown -s -t 0” as an argument to system function. If you wish to restart your computer then you can write “shutdown -r”.

If you are using Turbo C Compiler then execute your file from folder. Press F9 to build your executable file from source program. When you run from within the compiler by pressing Ctrl+F9 it may not work.

C programming code for Windows XP

#include <stdio.h>
#include <stdlib.h>

main()
{
   char ch;

   printf("Do you want to shutdown your computer now (y/n)n");
   scanf("%c",&ch);

   if (ch == 'y' || ch == 'Y')
      system("C:\WINDOWS\System32\shutdown -s");

   return 0;
}




C programming code for Windows 7

#include <stdio.h>
#include <stdlib.h>

main()
{
   char ch;

   printf("Do you want to shutdown your computer now (y/n)n");
   scanf("%c",&ch);

   if (ch == 'y' || ch == 'Y')
      system("C:\WINDOWS\System32\shutdown /s");

   return 0;
}

To shutdown immediately use “C:\WINDOWS\System32\ shutdown /s /t 0”. To restart use /r instead of /s.

C programming code for Ubuntu Linux

#include <stdio.h>

int main() {
  system("shutdown -P now");
  return 0;
}


You need to be logged in as root user for above program to execute otherwise you will get the message shutdown: Need to be root, now specifies that you want to shutdown immediately. ‘-P’ option specifes you want to power off your machine. You can specify minutes as:

shutdown -P “number of minutes”

For more help or options type at terminal: man shutdown.

Share

Write a C++ program to write number 1 to 100 in a data file NOTES.TXT

February 12th, 2013, posted in C++
Share
#include<fstream.h>

int main()
{
	ofstream fout;
	fout.open("NOTES.TXT");
	for(int i=1;i<=100;i++)
		fout<<i<<endl;
	fout.close();
	return 0;
}
Share

A for Apple, B for Butterfly

August 16th, 2011, posted in Art
Share

This is how I make A for Apple…. B for Butterfly…C for Cat….

Scarface_sketches

Share