Background Image

FORUM

DJ
조회 수 167 추천 수 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 Views21
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4452
    read more
  3. blob select

    Date2023.04.05 By네오랜덤 Views138
    Read More
  4. dba권한 상속

    Date2023.04.05 By네오랜덤 Views84
    Read More
  5. mac os m1 실행시 무응답 실행안됩니다.

    Date2023.04.04 By시나몬빵 Views152
    Read More
  6. 함수/프로시져 구동시 필요한 java버젼

    Date2023.03.31 By네오랜덤 Views123
    Read More
  7. 큐브리드 설치 도중 취소한 후, 재설치가 불가능합니다.

    Date2023.03.28 By복괴 Views154
    Read More
  8. where in () 서브쿼리 관련 문의입니다

    Date2023.03.27 By제리리 Views114
    Read More
  9. 한글을 입력받아 한글을 리턴하는 CUBRID JAVA StoredProcedure 작성시 window 환경에서 리턴 값이 깨져서 출력 됨

    Date2023.03.22 By두목원슝 Views164
    Read More
  10. 큐브리드 DAMO(암호화)관련 버전 호환관련하여 문의드립니다.

    Date2023.03.20 By초코초코초 Views230
    Read More
  11. cubrid manager 에러??

    Date2023.03.20 By11시38분 Views221
    Read More
  12. PreparedStatement.executeBatch에서 일부 데이터의 오류 시 반환 값 문의

    Date2023.03.18 By새옹지마 Views341
    Read More
  13. db생성경로가 db테이블과 결과조회에 영향을 미치나요?

    Date2023.03.15 Bydfdfdd Views120
    Read More
  14. SQL statement violated NOT NULL constraint

    Date2023.03.15 Byyoo Views164
    Read More
  15. 콤마로 split하는 기능 구현 관련 문의

    Date2023.03.15 By플레이어블 Views301
    Read More
  16. insert문에서 replace

    Date2023.03.15 Byyoo Views123
    Read More
  17. cubrid 파라미터 바인딩

    Date2023.03.14 ByDJ Views167
    Read More
  18. /home/jenkins/workspace/cubrid_release_10.1/src/transaction/boot_cl.c, line 1138 CODE = -971 Tran = -1, EID = 1Program 'tranlist' (pid ) connected to database server 'test' on the host 'localhost'

    Date2023.03.13 Byjmkim Views194
    Read More
  19. macOS CUBRID 다운로드 질문

    Date2023.03.13 Bybk9395 Views195
    Read More
  20. CUBRID 11.2 & CUBRID Aadmin 11.1 오류 문의

    Date2023.03.08 By붉은구름 Views135
    Read More
  21. 도커에서 설치시 접속 문의드립니다.

    Date2023.03.07 By핫산 Views385
    Read More
  22. 특수문자 포함 LIKE검색

    Date2023.03.06 BySEO Views154
    Read More
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 ... 200 Next
/ 200

Contact Cubrid

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