웹프로그래밍

Global It Leader!!


컴퓨터언어


 
 

Mysql [C#/PDA]PDA에서 MySQL 접속 예제

페이지 정보

작성자 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 1건 조회 1회 작성일 25-12-20 22:21

본문

MySQL에서 .net compact framework용 connector를 제공합니다.


connector를 설치하면 간단한 예제 및 dll 파일이 포함되어있습니다.


첨부된 파일은 MySql.Data.CF.dll 파일입니다. 첨부 파일 수신 후 참조에 추가 후 작업하면 됩니다.


아래의 소스는 DB 접속하여 자료 조회하여 데이타그리드에 바인딩하는 코드입니다.


using MySql.Data.MySqlClient;

private void button1_Click(object sender, EventArgs e)

    string myConnectionString = "server=***.***.***.***;uid=uid;pwd=pwd;database=database;";

    MySqlConnection conn = new MySqlConnection(myConnectionString);

    try

        conn.Open();

        DataSet ds = new DataSet();

        string sql = "select * from table";

        MySqlDataAdapter adpt = new MySqlDataAdapter(sql, conn);

        adpt.Fill(ds, "Tab1");

        dataGrid1.DataSource = ds.Tables[0];

        conn.Close();

}


첨부파일

댓글목록

운영자님의 댓글

no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 작성일

vbnet
Imports MySql.Data.MySqlClient
Imports System.Data

Public Class Form1
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        ' 1. 연결 문자열 설정 (실제 서버 정보로 변경하세요)
        Dim myConnectionString As String = "server=***.***.***.***;uid=uid;pwd=pwd;database=database;"

        ' 2. 연결 객체 생성
        Dim conn As New MySqlConnection(myConnectionString)

        Try
            ' 3. 연결 열기
            conn.Open()

            ' 4. 데이터셋 및 쿼리 설정
            Dim ds As New DataSet()
            Dim sql As String = "select * from table"

            ' 5. 어댑터를 이용해 데이터 채우기
            Dim adpt As New MySqlDataAdapter(sql, conn)
            adpt.Fill(ds, "Tab1")

            ' 6. DataGrid에 데이터 바인딩
            ' PDA(Compact Framework)의 DataGrid는 DataSource만 지정하면 됩니다.
            dataGrid1.DataSource = ds.Tables(0)

            ' 7. 연결 닫기
            conn.Close()

        Catch ex As MySqlException
            ' 에러 발생 시 메시지 출력
            MessageBox.Show(ex.Message)
        Finally
            ' 예외 발생 여부와 상관없이 연결이 열려있다면 닫기
            If conn.State = ConnectionState.Open Then
                conn.Close()
            End If
        End Try
    End Sub
End Class

전체 441
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
공지 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9197 04-08
공지 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 13643 01-07
열람중 Mysql no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2 12-20
438 VB no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1253 09-03
437 VB no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1644 09-03
436 VB no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1866 08-21
435 VB no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2176 07-20
434 VB no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2904 07-20
433 그누보드스킨 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3793 02-23
432 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4033 02-23
431 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4351 01-20
430 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5270 01-20
429 HTML no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10919 12-06
428 HTML no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8765 12-06
427 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5049 10-22
426 그누보드스킨 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4512 10-21
425 그누보드스킨 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5058 10-21
424 그누보드스킨 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4426 10-15
423 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4119 08-18
422 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5070 07-19