웹프로그래밍

Global It Leader!!


컴퓨터언어


 
 

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

페이지 정보

작성자 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 1건 조회 72회 작성일 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

전체 46
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
열람중 Mysql no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 72 12-20
45 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3998 09-07
44 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4511 11-02
43 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6163 11-02
42 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6746 03-28
41 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5455 07-31
40 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4929 09-02
39 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4769 09-02
38 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4995 03-20
37 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4975 12-31
36 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5040 12-18
35 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6051 12-18
34 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4828 12-18
33 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4956 11-10
32 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5395 07-29
31 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5082 06-20
30 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5564 03-28
29 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5463 08-17
28 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6261 08-16
27 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5440 08-16