473,388 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Connection to MySQL via the network

this code works perfectly when i use it on the server where mySQL is
installed, but i have a security error when i use it on a client computer.
I don't know how i can change that.
using System;
using System.Data.Odbc;

class database
{
// OleDbConnection oConn;
// OleDbCommand oCmd;

public void setConnection()
{
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=192.168.1.2;" +
"DATABASE=golf;" +
"UID=root;" +
"PASSWORD=;" +
"OPTION=3";
OdbcConnection myConnection = new OdbcConnection(MyConString);

try
{
// myConnection = new OleDbConnection(MyConString);
string mySelectQuery = "SELECT * FROM golfnews";

myConnection.Open();
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myCommand.CommandTimeout = 20;
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
int i = 0;

while (myReader.Read())
{
Console.WriteLine(myReader.ToString() + i++ );
}
myReader.Close();
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
finally
{
myConnection.Close();
}
}
}

class Prog
{
static void Main()
{
database db1 = new database();
db1.setConnection();
}
}
Nov 15 '05 #1
2 2182
KaHuNa,

What exactly is the exception that you are getting?

Also, when running it on a client computer, is it running in ASP.NET
perhaps (where the ASP.NET application is the client ot the MySQL server).
If not, are you sure that you have rights to the server and to the network
as well.

i

"KaHuNa" <ka****@quickemail.de> wrote in message
news:40********@news.vo.lu...
this code works perfectly when i use it on the server where mySQL is
installed, but i have a security error when i use it on a client computer.
I don't know how i can change that.
using System;
using System.Data.Odbc;

class database
{
// OleDbConnection oConn;
// OleDbCommand oCmd;

public void setConnection()
{
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=192.168.1.2;" +
"DATABASE=golf;" +
"UID=root;" +
"PASSWORD=;" +
"OPTION=3";
OdbcConnection myConnection = new OdbcConnection(MyConString);

try
{
// myConnection = new OleDbConnection(MyConString);
string mySelectQuery = "SELECT * FROM golfnews";

myConnection.Open();
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myCommand.CommandTimeout = 20;
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
int i = 0;

while (myReader.Read())
{
Console.WriteLine(myReader.ToString() + i++ );
}
myReader.Close();
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
finally
{
myConnection.Close();
}
}
}

class Prog
{
static void Main()
{
database db1 = new database();
db1.setConnection();
}
}

Nov 15 '05 #2
i don't have exception i have that:( sorry for the french but i don't know
the translation for that)

Exception non gérée : System.Security.SecurityException: Failure of request.
at database.setConnection()
at Prog.Main()

Le jeu autorisé de l'assembly défaillant était :
<PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.EnvironmentPerm ission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Read="USERNAME"/>
<IPermission class="System.Security.Permissions.FileDialogPermi ssion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Security.Permissions.FileIOPermissio n,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Read="J:\Prog\C#\"
PathDiscovery="J:\Prog\C#\"/>
<IPermission
class="System.Security.Permissions.IsolatedStorage FilePermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="AssemblyIsolationByUser"
UserQuota="9223372036854775807"
Expiry="9223372036854775807"
Permanent="True"/>
<IPermission class="System.Security.Permissions.ReflectionPermi ssion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="ReflectionEmit"/>
<IPermission class="System.Security.Permissions.SecurityPermiss ion,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Assertion, Execution, BindingRedirects"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Net.DnsPermission, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Unrestricted="true"/>
<IPermission class="System.Drawing.Printing.PrintingPermission,
System.Drawing, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="DefaultPrinting"/>
<IPermission class="System.Diagnostics.EventLogPermission, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<Machine name="."
access="Instrument"/>
</IPermission>
<IPermission class="System.Security.Permissions.UrlIdentityPerm ission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Url="file://J:/Prog/C#/database.exe"/>
<IPermission class="System.Security.Permissions.ZoneIdentityPer mission,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
version="1"
Zone="Intranet"/>
</PermissionSet>
Exit code: -532459699 , E0434F4Dh
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> a écrit
dans le message de news:OX**************@TK2MSFTNGP09.phx.gbl...
KaHuNa,

What exactly is the exception that you are getting?

Also, when running it on a client computer, is it running in ASP.NET
perhaps (where the ASP.NET application is the client ot the MySQL server).
If not, are you sure that you have rights to the server and to the network
as well.

i

"KaHuNa" <ka****@quickemail.de> wrote in message
news:40********@news.vo.lu...
this code works perfectly when i use it on the server where mySQL is
installed, but i have a security error when i use it on a client computer. I don't know how i can change that.
using System;
using System.Data.Odbc;

class database
{
// OleDbConnection oConn;
// OleDbCommand oCmd;

public void setConnection()
{
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=192.168.1.2;" +
"DATABASE=golf;" +
"UID=root;" +
"PASSWORD=;" +
"OPTION=3";
OdbcConnection myConnection = new OdbcConnection(MyConString);

try
{
// myConnection = new OleDbConnection(MyConString);
string mySelectQuery = "SELECT * FROM golfnews";

myConnection.Open();
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myCommand.CommandTimeout = 20;
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
int i = 0;

while (myReader.Read())
{
Console.WriteLine(myReader.ToString() + i++ );
}
myReader.Close();
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
finally
{
myConnection.Close();
}
}
}

class Prog
{
static void Main()
{
database db1 = new database();
db1.setConnection();
}
}


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pandis Ippokratis | last post by:
Hi, I have the following problem: I am implementing a server in Java and I use jdbc to connect to an Oracle 9.0.2 db. All seem to work fine, but when I intensionally cause a network failure...
0
by: Adam Carmichael | last post by:
------=_NextPart_000_4BD9_01C34F2E.785DA9C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I am trying to build a MySQL Server running...
0
by: Pav Lucistnik | last post by:
Hi folks, we're seeing strange behaviour of mysql connections over network here lately. Server and client are on different machines. Server (corpdb) is Mysql 3.23.52 on FreeBSD 4.6.2-RELEASE,...
0
by: Gena | last post by:
Hi, I'm getting the following exception and I'm not really sure why I'm getting it. ***Exception: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection timed...
0
by: David | last post by:
Hi, I have a local user on our network running MS Access 2003 (on Win XP Home), which needs to connect to a Back-End MySQL DB on our Cobalt Qube 3 Server. I installed the correct software to...
4
by: DJJ | last post by:
I am trying to connect to a server hosting a MySQL database called "BusinessMind" using the Query Browser. I keep getting the following message listed below. Do I have to somehow register my...
4
by: Bob Sanderson | last post by:
I am trying to set up an ODBC DSN to our company MySQL database so that I can use a MS Access front end. I am using the MySQL ODBC 3.51 driver. The database is running off of Apache on our Windows...
1
by: Sanny | last post by:
I am using a MySql database for chat application. Every 3 seconds the database is searched for various details. I would like to know How many individual can it handle at a time. Say there...
1
by: Israel | last post by:
I'm running into this problem where my database connection seems to get disconnected by something unknown to me. My server is running locally so any network problems shouldn't have any affect on...
1
by: sang | last post by:
Hi I am working in a Mysql and Java Platform. For my Project some computers are connected in network to share the files and etc. I want to access the mysql database through the network...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.