Jump to content

rhonin

Members
  • Posts

    3
  • Joined

  • Last visited

rhonin's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. thank you very much ! This has finally worked :)/&--#62; I am posting code for ppl with same issue in future. class Dataconnect { public void ConnectToDatabase() { int id = 6; string meno = "Rhonin"; int pocet = 150000; string db = "server = darkangels.heliohost.org; database = rhonin_da; uid = rhonin_da; password = *********"; MySqlConnection conn = new MySqlConnection(db); MySqlCommand command; conn.Open(); try { command = conn.CreateCommand(); command.CommandText = "INSERT INTO Suroviny (ID, Meno, Pocet) VALUES (@id, @meno, @pocet)"; command.Parameters.AddWithValue("id", id); command.Parameters.AddWithValue("meno", meno); command.Parameters.AddWithValue("pocet", pocet); command.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
  2. did not help, still not working :(/&--#62; i used domain name: darkangels.heliohost.org
  3. Hello, i am trying to connect to mysql database remotely using C# applications (code is below). However i will always get error on connection.Open() -> server could not be found. I tryed to connect to database localy from web and that worked fine. In remote access in Cpanel i wrote just % (i did not understand that very well). I tryed to change server from Stevie.heliohost.org to IP with port but did not work using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; namespace Databaza { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // } private void button1_Click(object sender, EventArgs e) { Dataconnect bublatanka = new Dataconnect(); bublatanka.ConnectToDatabase(); } } class Dataconnect { public void ConnectToDatabase() { int id = 2; string meno = "Hallder"; int pocet = 2500; string db = "server = 65.19.143.2:3306; database = rhonin_da; uid = rhonin_da; password = **********"; ; using (SqlConnection connection = new SqlConnection(db)) { using (SqlCommand command = new SqlCommand("INSERT INTO Suroviny (ID, Meno, Suroviny) VALUES (@id, @meno, @pocet", connection)) { command.Parameters.Add(new SqlParameter("id", id)); command.Parameters.Add(new SqlParameter("meno", meno)); command.Parameters.Add(new SqlParameter("pocet", pocet)); connection.Open(); command.ExecuteNonQuery(); } } } } }
×
×
  • Create New...