==========================================================================================

C#

==========================================================================================

<C#>


=OLE => 기본으로 다 제공해주고 있으나 특화된 기능은 없음

1. string strconn = "";


2. conn.ConnectionString = '';


==SQL






=ChangeDatabase 

SQL Helpre.cs 만든다 : 중대형 프로젝트 공유


=Dispose : 가비지 처리





=@    => 사용시 경로 \하나만 입력

        => 미사용시 경로 \\입력





=데이터베이스 조작








=






-visual c#










=




=




=




=




=실습


--CONSOLE

-1.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;

namespace _20150622
{
    
class Program
    {
        
static void Main(string[] args)
        {
            List
<string[]> lst1 = new List<string[]>();
            string[] str1
= {"이 름\t""나 이\t""전화번호"};
            string StrSQL 
= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\Human.mdb";
            var Conn 
= new OleDbConnection(StrSQL);
            Conn.Open();

            var Comm 
= new OleDbCommand("SELECT * FROM HumanInfo", Conn);
            var myRead 
= Comm.ExecuteReader();
            
while (myRead.Read())
            {
                var strArray 
= new String[] { myRead["M_Name"].ToString(),
                myRead[
"M_Age"].ToString(), myRead["M_Phone"].ToString() };
                lst1.Add(strArray);
            }
            myRead.Close();
            Conn.Close();
            foreach (var a in str1)
                Console.Write(
"{0}", a);

            Console.WriteLine();

            foreach (var a in lst1)
            {
                foreach (var b in a)
                {
                    Console.Write(
"{0}\t", b);
                }
                Console.WriteLine();
            }
        }
    }
}


-2.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;

namespace ConsoleApplication26
{
    
class Program
    {
        
        
static void Main(string[] args)
        {
          
//string StrSQL = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Human1.mdb;Mode=ReadWrite"; //데이터베이스 연결 문자열
            string StrSQL = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Human1.mdb;Mode=ReadWrite"//데이터베이스 연결 문자열
            OleDbConnection conn = new OleDbConnection();
            conn.ConnectionString 
= StrSQL;
            
try
            {
                conn.Open();
                OleDbCommand cmd 
= new OleDbCommand("select * from humaninfo", conn);
                OleDbDataReader read 
= cmd.ExecuteReader();
                Console.WriteLine(
"이름" + "\t" + "나이" + "\t" + "번호");
                
while (read.Read())
                {
                     Console.WriteLine(read[
1] + "\t" + read[2] + "\t" + read[3]);
                }
            }

            
catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
    }
}




--WINDOW


-DataGridView



















==========================================================================================

C++

==========================================================================================


<C++>



=가상함수 테이블


vtable

vptr





#include <iostream>
using namespace std;

class B
{
    
private:
        
int memB;
    
public:
        B():memB(
0x11111111){}
        
virtual void f1()
        {
            cout 
<< "B::F1\n";
        }
        
virtual void f2()
        {
            cout 
<< "B::F2\n";
        }
        virtual void f3()
        {
            cout 
<< "B::F3\n"
;
        }

        
virtual void normal()
        {
            cout 
<< "non virtual\n";
        }

};

class D : public B
{
    
private:
        
int memD;
    
public:
        D():memD(
0x22222222){}
        virtual void f1()
        {
            cout 
<< "D::F1\n";
        }
        virtual void f2()
        {
            cout 
<< "D::F2\n"
;
        }

};

int main()
{
    B *pB;
    B b;
    D d;

    pB 
= &b;
    pB-
>f2();
    pB 
= &d;
  
  pB->f2();
    pB->f3();

    
return 0;
}







=순수 가상함수(자바/C# => 인터페이스)

:virtual void Draw()=0;

:추상클래스(순수가상함수존재)객체생성 불가

        => 파생 클래스에서 함수구현 => 파생 클래스 객체생성 가능

:용도 => 상속시 강제(뼈대)


#include <iostream>
using namespace std;

class Graphic // 추상클래스(순수가상함수 포함하는 클래스) 객체생성 불가
{
    
public:
        
virtual void Draw() = 0//순수가상함수 : 구현 X
};


class Line public Graphic
{
    
public:
        
virtual void Draw()
        {
            cout 
<< "선을 긋습니다\n";
        }

};

class Circle public Graphic
{
    
public:
        virtual void Draw()
        {
            cout 
<< "동그라미 그렸다 치고\n";
        }

};

class Rect public Graphic
{
    
public:
  
      virtual void Draw()
        {
            cout 
<< "요건 사각형 입니다.\n";
        }

};

int main()
{
    
int i;

//    Grathic G; // 추상클래스(순수가상함수 포함하는 클래스) 객체생성 불가
    Graphic *pG[3]; // 포인터는 가능


    pG[0= new Line;
    pG[
1= new Circle;
    pG[
2= new Rect;

    
for(i = 0; i < 3; ++i)
    {
        pG[i]-
>Draw();
    }

    
for(i = 0; i < 3; ++i)
    {
        
delete pG[i];
    }

    
return 0;
}







=







'2015 스마트 콘트롤러 > 업무일지' 카테고리의 다른 글

20150624  (0) 2015.06.24
20150623  (0) 2015.06.23
20150619  (0) 2015.06.21
20150618  (0) 2015.06.18
20150617  (0) 2015.06.17
Posted by ahj333
,