Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

ich versuche ein tool zu schreiben, was über C# mit einer MySQL Datenbank verbindet. Irgendwie schmeißt er mir aber (datenbank ist extern!) immer ein Access denied.

Woran kann das liegen?


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using MySql.Data.MySqlClient;


namespace DB_Extern_Checker

{

    public partial class DBChecker : Form

    {

        public DBChecker()

        {

            try

            {

                InitializeComponent();

                lblDatabase.Visible = false;

                lblResult.Visible = false;

                lblResponse.Visible = false;

            }

            catch(Exception ex)

            {

                throw ex;

            }

        }


        private void btnReset_Click(object sender, EventArgs e)

        {

            try

            {

                tbHost.Text = "127.0.0.1";

                tbUsername.Text = "Username";

                tbPassword.Text = "******";

                tbPort.Text = "21";

            }

            catch(Exception ex)

            {

                throw ex;

            }

        }


        private void btnCheck_Click(object sender, EventArgs e)

        {

            try

            {

                string connectionString = "SERVER="+tbHost.Text+";" + "DATABASE="+tbDatabase.Text+ ";" + "UID="+tbUsername.Text+ ";" + "PASSWORD="+tbDatabase.Text+";";

                MySqlConnection connection = new MySqlConnection(connectionString);

                connection.Open();

                connection.Close();

                //MySqlCommand command = connection.CreateCommand();

                //command.CommandText="SELECT * FROM ";

            }

            catch(Exception ex)

            {

                lblResponse.Visible = true;

                lblResponse.Text = ex.Message.ToString();

            }


        }

    }

}


Danke und Grüß

SeToY

  • Autor

Hallo Frank,

(datenbank ist extern!)

Ja, kann man :)

Liebe Grüße

Edit:

Ich geh kaputt...


string connectionString = "SERVER="+tbHost.Text+";" + "DATABASE="+tbDatabase.Text+";" + "UID="+tbUsername.Text+";" + "PASSWORD="+tbDatabase.Text+";";

->

string connectionString = "SERVER="+tbHost.Text+";" + "DATABASE="+tbDatabase.Text+";" + "UID="+tbUsername.Text+";" + "PASSWORD="+tbPassword.Text+";";

:upps:upps:upps

Bearbeitet von SeToY

Bedeutet?

Er übergibt als Passwort einfach den falschen parameter. CopyPaste bringt halt auch Nachteile.

Generell stimme ich lbm aber zu... benutze den Builder

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.