小编usr*_*951的帖子

我的第一个c#声明......这样做的正确方法是什么?

正如标题所示,这是我的第一个C#尝试,所以请放轻松.(作为一个新手,我保证会为C#专业人员提出一些简单的问题,以便为您提供一些简单的观点!)我正在使用ExcelDNA在Excel中创建一个UDF,它将查询我们的mysql数据库.我添加了ExcelDNA和mysql连接器dll作为参考.我有以下代码,它会产生一些错误:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;  
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
using ExcelDna.Integration;
using MySql.Data.MySqlClient;

namespace my_test
{
public partial class ThisAddIn
{
    [ExcelFunction(Description = "Multiplies two numbers", Category = "Useful functions")]
    public static MultiplyThem(string[] args)
    {

        string connString = "Server=localhost;Port=3306;Database=test;Uid=root;password=p-word";
        MySqlConnection conn = new MySqlConnection(connString);
        MySqlCommand command = conn.CreateCommand();
        command.CommandText = "SELECT field_value FROM customers";
        try
        {
            conn.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        string myvariable = "bad"; …
Run Code Online (Sandbox Code Playgroud)

c# mysql excel-dna

3
推荐指数
1
解决办法
726
查看次数

标签 统计

c# ×1

excel-dna ×1

mysql ×1