Background Image

FORUM

DJ
조회 수 5277 추천 수 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 Views143886
    read more
  2. mac os m1 실행시 무응답 실행안됩니다.

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

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

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

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

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

    Date2023.03.20 By초코초코초 Views5085
    Read More
  8. cubrid manager 에러??

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

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

    Date2023.03.15 Bydfdfdd Views4492
    Read More
  11. SQL statement violated NOT NULL constraint

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

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

    Date2023.03.15 Byyoo Views4622
    Read More
  14. cubrid 파라미터 바인딩

    Date2023.03.14 ByDJ Views5277
    Read More
  15. /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 Views4955
    Read More
  16. macOS CUBRID 다운로드 질문

    Date2023.03.13 Bybk9395 Views12031
    Read More
  17. CUBRID 11.2 & CUBRID Aadmin 11.1 오류 문의

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

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

    Date2023.03.06 BySEO Views4916
    Read More
  20. cubrid admin 질문 드립니다.

    Date2023.03.06 By초코초코초 Views4471
    Read More
  21. plugin방식 호출

    Date2023.03.04 By네오랜덤 Views4685
    Read More
Board Pagination Prev 1 ... 17 18 19 20 21 22 23 24 25 26 ... 213 Next
/ 213

Contact Cubrid

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