I want make a connection with MySQL (don't know why, i need, that's all
; ) ) in C#
but i don't know a lots the OleDbConnection, i have do that:
using System;
using System.Data.OleDb;
class database
{
// OleDbConnection oConn;
// OleDbCommand oCmd;
public void setConnection()
{
OleDbConnection myConnection = new OleDbConnection(
"Provider=MySQL ODBC 3.51 Driver;Data
Source=192.168.1.2;Database=golf;");
string mySelectQuery = "SELECT * FROM golfnews";
myConnection.Open();
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myCommand.CommandTimeout = 20;
OleDbDataReader myReader;
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader.ToString());
}
myReader.Close();
myConnection.Close();
}
}
class Prog
{
static void Main()
{
database db1 = new database();
db1.setConnection();
}
}
but i receive in the output a security error :
exception does not generated : System.Security.SecurityException: failure
from the 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>
Somebody can help me to find the error, and what more i have a login and a
pass to connect to MySQL but i don't know where i put these in the code....
Thanks 3 1377
Well, you would want to put the actual connection to the database in a
try/catch block and output error messages in a MessageBox or something as
the error messages are easier to read and more informative. Note that if
it fails, you should clean up code in a finally block.
You probably need to add User id=myuser;Password=mypass; in the
connectionstring.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Hi,
Username and password data can be specified in the oleDb
connection string with the "User ID" and "Password"
keywords.
Shamshins Itamar -----Original Message----- I want make a connection with MySQL (don't know why, i
need, that's all ; ) ) in C# but i don't know a lots the OleDbConnection, i have do
that: using System; using System.Data.OleDb;
class database { // OleDbConnection oConn; // OleDbCommand oCmd;
public void setConnection() { OleDbConnection myConnection = new OleDbConnection( "Provider=MySQL ODBC 3.51 Driver;Data Source=192.168.1.2;Database=golf;"); string mySelectQuery = "SELECT * FROM golfnews";
myConnection.Open(); OleDbCommand myCommand = new OleDbCommand
(mySelectQuery, myConnection); myCommand.CommandTimeout = 20; OleDbDataReader myReader; myReader = myCommand.ExecuteReader();
while (myReader.Read()) { Console.WriteLine(myReader.ToString()); } myReader.Close();
myConnection.Close(); } }
class Prog { static void Main() { database db1 = new database(); db1.setConnection(); } }
but i receive in the output a security error :
exception does not generated :
System.Security.SecurityException: failurefrom the 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.IsolatedStorag eFilePerm
ission, 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>
Somebody can help me to find the error, and what more i
have a login and apass to connect to MySQL but i don't know where i put
these in the code.... Thanks
.
Nothing have change!!!!!!!!
"Shamshins Itamar" <an*******@discussions.microsoft.com> a écrit dans le
message de news:07****************************@phx.gbl...
Hi,
Username and password data can be specified in the oleDb
connection string with the "User ID" and "Password"
keywords.
Shamshins Itamar -----Original Message----- I want make a connection with MySQL (don't know why, i
need, that's all ; ) ) in C# but i don't know a lots the OleDbConnection, i have do
that: using System; using System.Data.OleDb;
class database { // OleDbConnection oConn; // OleDbCommand oCmd;
public void setConnection() { OleDbConnection myConnection = new OleDbConnection( "Provider=MySQL ODBC 3.51 Driver;Data Source=192.168.1.2;Database=golf;"); string mySelectQuery = "SELECT * FROM golfnews";
myConnection.Open(); OleDbCommand myCommand = new OleDbCommand
(mySelectQuery, myConnection); myCommand.CommandTimeout = 20; OleDbDataReader myReader; myReader = myCommand.ExecuteReader();
while (myReader.Read()) { Console.WriteLine(myReader.ToString()); } myReader.Close();
myConnection.Close(); } }
class Prog { static void Main() { database db1 = new database(); db1.setConnection(); } }
but i receive in the output a security error :
exception does not generated :
System.Security.SecurityException: failurefrom the 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.IsolatedStorag eFilePerm
ission, 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>
Somebody can help me to find the error, and what more i
have a login and apass to connect to MySQL but i don't know where i put
these in the code.... Thanks
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: G-Fit |
last post by:
Hello group,
I have several servers hosting SQL databases. On each of them, I have
several databases. All those databases have the same structure (even those
on different servers), only the data...
|
by: pradeep_TP |
last post by:
Hi all,
I have a few questions that I have been wanting to ask for long. These are
all related to ADO.net and specifically to conenction to database.
1) If I have opened a connection to a...
|
by: Chris Szabo |
last post by:
I've created a data access layer for a .NET web
application. I'm using C# and framework 1.1. I'm getting
an error from time to time when I close a connection
saying: ...
|
by: Rob Nicholson |
last post by:
We're getting an occasional occurrence of the following error when two users
try and open the same record in our ASP.NET app:
"There is already an open DataReader associated with this Connection...
|
by: Eric Sabine |
last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET
connection object, SQLConnection to be exact) and then I came across the
following in some microsoft code.
If Not cn Is Nothing...
|
by: Martin B |
last post by:
Hallo!
I'm working with C# .NET 2.0, implementing Client/Server Applications which
are connecting via Network to SQL-Server or Oracle Databases.
To stay independent from the underlaying Database...
|
by: fniles |
last post by:
I am using VS2003 and connecting to MS Access database.
When using a connection pooling (every time I open the OLEDBCONNECTION I use
the exact matching connection string),
1. how can I know how...
|
by: fniles |
last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like
the following:
In the main form load I open a connection using a connection string that I
stored in a global variable...
|
by: Robert Avery |
last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and
displayed for the user all connection events, so that I could easily
see what SQL was taking a long time, and when it freezes, I...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |