Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6691221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:43:36+00:00 2026-05-26T05:43:36+00:00

I have been heavily contemplating adding the Embedded MYSQL Server Library into my application.

  • 0

I have been heavily contemplating adding the Embedded MYSQL Server Library into my application. My software is a layer between a Game Server and a Web Management Panel that provides extra functionality. Many of our customers have been requesting MySQL databases for their servers (since this is what their plugins are developed to use), and being able to run one within my software rather than manually set them up would be fantastic.

  • Is there a .NET wrapper for this library I am missing?

  • The software being ran by my application will need to be able to connect to it, but the software is obviously being ran locally. Will this work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:43:36+00:00Added an answer on May 26, 2026 at 5:43 am

    i’m not aware of any .NET wrapper for this library although i remember there was a talk about introducing support for this library in the .NET Connector from version 5. I can’t find any information about that right now though.

    There is some sample code out there on the web which you can extend your code upon. I quess the most complete would be http://forums.mysql.com/read.php?38,67281,67917 ->

    using System;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    using System.Configuration;
    
    class EntryPoint
    {
        [DllImport("libmySQL.dll")]
        static extern IntPtr mysql_init(IntPtr mysql);
    
        [DllImport("libmySQL.dll")]
        static extern IntPtr mysql_fetch_lengths(IntPtr result);
    
        [DllImport("libmySQL.dll")]
        static extern IntPtr mysql_store_result(IntPtr mysql);
    
        [DllImport("libmySQL.dll")]
        static extern IntPtr mysql_fetch_row(IntPtr result);
    
        [DllImport("libmySQL.dll")]
        static extern IntPtr mysql_real_connect(IntPtr mysql, string host, string user, string passwd, string db, uint port, string unix_socket, uint client_flag);
    
        [DllImport("libmySQL.dll")]
        static extern uint mysql_field_count(IntPtr mysql);
    
        [DllImport("libmySQL.dll")]
        static extern string mysql_error(IntPtr mysql);
    
        [DllImport("libmySQL.dll")]
        static extern int mysql_real_query(IntPtr mysql, string query, uint length);
    
        static Array MarshalArray(Type structureType, IntPtr arrayPtr, int length)
        {
            if (structureType == null)
                throw new ArgumentNullException("structureType");
            if (!structureType.IsValueType)
                throw new ArgumentException("Only struct types are supported.", "structureType");
            if (length < 0)
                throw new ArgumentOutOfRangeException("length", length, "length must be equal to or greater than zero.");
            if (arrayPtr == IntPtr.Zero)
                return null;
            int size = System.Runtime.InteropServices.Marshal.SizeOf(structureType);
            Array array = Array.CreateInstance(structureType, length);
            for (int i = 0; i < length; i++)
            {
                IntPtr offset = new IntPtr((long)arrayPtr + (size * i));
                object value = System.Runtime.InteropServices.Marshal.PtrToStructure(offset, structureType);
                array.SetValue(value, i);
            }
            return array;
        }
    
    
        static void mysql_real_query(IntPtr mysql, string query)
        {
            int result = (query != null) ? mysql_real_query(mysql, query, (uint)query.Length) : mysql_real_query(mysql, null, 0);
            if (result == 0)
                return;
            throw new ApplicationException(mysql_error(mysql));
        }
    
        static int Main(string[] args)
        {
            IntPtr ptr = mysql_init(IntPtr.Zero);
            Debug.Assert(ptr != IntPtr.Zero);
    
            IntPtr mysql = mysql_real_connect(ptr, ConfigurationSettings.AppSettings["server"], ConfigurationSettings.AppSettings["username"], ConfigurationSettings.AppSettings["password"], ConfigurationSettings.AppSettings["database"], 0, null, 0);
            Debug.Assert(ptr != IntPtr.Zero, mysql_error(ptr));
    
            string query = "SELECT * FROM proxy_servers";
            Console.WriteLine("Executing query: {0}", query);
            mysql_real_query(mysql, query);
    
            IntPtr result = mysql_store_result(mysql);
            Debug.Assert(result != IntPtr.Zero, mysql_error(mysql));
    
            uint fieldCount = mysql_field_count(mysql);
            Console.WriteLine("field count: {0}", fieldCount);
    
            for (IntPtr ptrRow = mysql_fetch_row(result); ptrRow != IntPtr.Zero; ptrRow = mysql_fetch_row(result))
            {
                IntPtr[] mysqlRow = (IntPtr[])MarshalArray(typeof(IntPtr), ptrRow, (int)fieldCount);
                IntPtr ptrLengths = mysql_fetch_lengths(result);
                uint[] lengths = (uint[])MarshalArray(typeof(uint), ptrLengths, (int)fieldCount);
                for (int i = 0; i < (int)fieldCount; i++)
                {
                    string str = Marshal.PtrToStringAnsi(mysqlRow[i], (int)lengths[i]);
                    Console.Write("{0}, ", str);
                }
                Console.WriteLine();
            }
            return 0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into game development recently and my first programming language is
I'm working on a small library for our in-company use, and have been heavily
I have been looking into IKVMing Apache's FOP project to use with our .NET
I have been contributing heavily to this open source project that aims to help
Hi have a repository checkout (SVN) which has been heavily modified by a team
I have been using Python's pickle module for implementing a thin file-based persistence layer.
In an application I have been building we rely on SharedPreferences quite a bit,
I have been heavily using grails with netbeans for one of my projects, I
I current use prototype library to handle ajax requests. I have been on stack
Me and my team have been heavily producing plugins for a Rails 2.3 app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.