Background Image

FORUM

DJ
조회 수 168 추천 수 0 댓글 3
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄


* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.

OS
Window11 pro
CUBRID Ver.
CUBRID 9.3 (9.3.9.0002) (64bit release build for Windows_NT)
CUBRID TOOL Ver.
10.2.0.0001  (64bit)
응용 환경(API)
odbc


* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.

 

에러 내용 및 재현 방법 재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보 CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------

 

namespace server
{
    public partial class login : Form
    {

        public struct cubridConn // cubrid 연결
        {
            public XmlDocument xmlConfig; // xml 설정 가져오기
            public string dbConnectString;
            public bool dbOpenState;
            public OdbcConnection dbConn;//큐브리드 연결.

        }

        public cubridConn _serverComm = new cubridConn();
        public login()
        {
            InitializeComponent();
            Thread_CubridConnect();

        }

        public Server socNaverBlog;
        private void login_Load(object sender, EventArgs e)
        {
            try
            {
                //xml 주소 
                _serverComm.xmlConfig = new XmlDocument();
                _serverComm.xmlConfig.Load(Application.StartupPath + "/login.xml"); // xml파일을 로드(시작점은 login.xml 파일로 부터)

                // database
                XmlNode dbConnectString = _serverComm.xmlConfig.SelectSingleNode("/DB_Connect");

              
                _serverComm.dbConnectString = dbConnectString.InnerText;

                //MessageBox.Show(_serverComm.dbConnectString);
            }
            catch (Exception)
            {


                MessageBox.Show("실행 파일 에러. 관리자에게 문의하세요.");
            }
        }

        private void Thread_CubridConnect()
        {
            System.Threading.Timer timerDB = new System.Threading.Timer(DB_Connect);
            
            timerDB.Change(0, 2000); //OK
        }

        object _lockobject;
        private void DB_Connect(object sender)
        {
            try
            {
                if (!_serverComm.dbOpenState)
                {
                    _serverComm.dbConn = new OdbcConnection(_serverComm.dbConnectString);
                    //MessageBox.Show(_serverComm.dbConnectString);
                    _serverComm.dbConn.Open();
                    _serverComm.dbOpenState = true;
                    if (_serverComm.dbConn.State == ConnectionState.Closed)
                        return;
                }
            }
            catch (OdbcException)
            {
            }
            catch (Exception ex)
            {

            }
            finally
            {
                _serverComm.dbConn.Close();
            }
        }
            signup signup = new signup();
        private void btn_new_Click(object sender, EventArgs e)
        {
            signup.ShowDialog();
        }
        Server serverSoc = new Server();

 

 


        private void btn_login_Click(object sender, EventArgs e)
        {
            string id = textBox1.Text; //①,②
            string pw = textBox2.Text; //①,②

          

            string userID = textBox1.Text;//③
            string userPW = textBox2.Text;//③

            //OdbcCommand cmd = new OdbcCommand();

            //cmd.CommandType = CommandType.Text;

            //cmd.CommandText = "SELECT id,pw FROM sock_table WHERE id = '" + id + "'&& pw = '" + pw + "';";

            //string query = "SELECT * FROM sock_table WHERE id=? and pw=?"; //①

            

            string sql_cub_sel = "SELECT * FROM sock_table WHERE id=? and pw=?"; ③

            string sql_cub_sel = "SELECT * FROM sock_table WHERE id=@id and pw=@pw"; ④
            //string sql_cub_ins = "INSERT INTO sock (id,pw) VALUES (@id,@pw);";
            //OdbcConnection conn = new OdbcConnection(_serverComm.dbConnectString);//①,②

            using (var connect = new OdbcConnection(_serverComm.dbConnectString))
            {

                try
                {
                    connect.Open(); //연결

                    using (var command = new OdbcCommand(sql_cub_sel, connect))
                    {
                        command.Parameters.AddWithValue("@id", userID);
                        command.Parameters.AddWithValue("@pw", userPW);

                        command.ExecuteNonQuery();

                        connect.Close();
                    }

                    MessageBox.Show(userID + "로그인 완료");
                    serverSoc.ShowDialog();
                }
                catch (Exception)
                {

                    throw;
                }

            }

         }

     }

}

 

로그인 버튼 클릭시 DB 에 있는 데이터를 select 해와서 로그인 하려고 하는데요, 

 파라미터 바인딩을 사용 하려고 합니다. 

 

보통 c#은 파라미터 바인딩 할 때 @변수 를 붙이는 데 큐브리드의 경우 쿼리에 @변수를 붙여서 실행하면 (④번 쿼리문의 경우) 

 

예외처리가 되지 않음

System.Data.Odbc.OdbcException: 'ERROR [HY000] [CUBRID][ODBC CUBRID Driver][-1070]Session variable '@id' not defined.[CAS INFO-10.10.10.60:33000,1,12988].'

 

이런 알림 문구가 뜹니다. 

 

③번 쿼리문 처럼 '?'를 넣으면 문제 없이 실행되는데

혹시 큐브리드만의 파라미터 바인딩 방식이 있는지 궁금합니다

 

 

  • ?
    큐브리드_김주현 2023.03.14 10:24
    큐브리드를 이용해 주셔서 감사합니다.

    ? 를 사용해야 하며, 순서를 지켜야 하는 제약만 있습니다.
    상세내용은 https://www.cubrid.org/manual/ko/11.2/api/adodotnet.html#id10 참고 바랍니다.
    감사합니다.
  • ?
    DJ 2023.03.14 10:44

    https://www.cubrid.org/manual/ko/9.2.0/sql/query/prepare.html
    @로 prepared statement에서 사용이 가능하다고 나오는데요, 이것도 사용 할 수 있는건가요??

  • ?
    큐브리드_김주현 2023.03.15 16:40
    네 prepare state문으로 사용하실 경우 가능합니다.

  1. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views49
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4458
    read more
  3. 8.4.4 charset. Collation 확인 방법

    Date2023.05.24 By네오랜덤 Views188
    Read More
  4. 8.4.4버젼 charset 확인

    Date2023.05.23 By네오랜덤 Views193
    Read More
  5. 쿼리 속도 차이 질문

    Date2023.05.18 By하얀미스 Views143
    Read More
  6. spring boot 에서 HikariPool-1 - Driver does not support get/set network timeout for connections. (java.lang.UnsupportedOperationException) 질문 드립니다.

    Date2023.05.18 Bykjaminam Views785
    Read More
  7. cci 프로그래밍에서 DB LINK 관련 문의

    Date2023.05.18 Byjjune1206 Views131
    Read More
  8. 큐브리드 매니저 실행이 오류

    Date2023.05.18 By청주시청 Views101
    Read More
  9. ddl 추출

    Date2023.05.17 By네오랜덤 Views105
    Read More
  10. 하나의 쿼리에서 복수 테이블 업데이트 방법 문의

    Date2023.05.17 By도담도담 Views136
    Read More
  11. cubrid driver 설치 문의

    Date2023.05.08 By고구망구망 Views438
    Read More
  12. 큐브리드 매니저 접속 이 안됩니다. 확인 요청 드립니다.

    Date2023.04.28 By뿡이 Views128
    Read More
  13. Fk값 가져오기

    Date2023.04.24 By네오랜덤 Views166
    Read More
  14. 서버 메모리 교체 및 ha 상 데이터 삭제 절차

    Date2023.04.20 By레피엘 Views113
    Read More
  15. java stored procedure 에 loadjava 로 jar 파일 로드 시 java.lang.ClassNotFoundException 에러 문의

    Date2023.04.18 By개미가불쌍해 Views147
    Read More
  16. Cubrid stored procedure 스케쥴 등록 형식

    Date2023.04.17 ByRoy Views112
    Read More
  17. 암호화 함수 MDB_ENC 질문입니다

    Date2023.04.17 ByBE-DEV Views82
    Read More
  18. auto_increment 추가 방법 문의

    Date2023.04.14 By부패방지운영팀 Views265
    Read More
  19. CUBRID 사용자 계정 생성 관련 문의

    Date2023.04.14 By몽키스패너 Views132
    Read More
  20. order by 이후 rownum이 의도와 다르게 찍힙니다.

    Date2023.04.14 By바보똥개 Views143
    Read More
  21. 백업 및 복구 시 cubrid 버전 간 호환 문의

    Date2023.04.13 By플레이어블 Views71
    Read More
  22. centos8에서 쉘스크립트 실행시 csql: command not found 오류 발생

    Date2023.04.13 Bykjn4345 Views180
    Read More
Board Pagination Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 200 Next
/ 200

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales