Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Strange behaviour (no replies)

$
0
0
Hi,
I playing around with the .net connector, a mysql server and asp.net.
The structure of my test table is
index int(11) (Unique and auto_increment)
path varchar(200)
count int(11)

I want to query this table and select an entry with a specific index.
My code:


mySQLConnection.Open();
MySqlCommand command = new MySqlCommand("SELECT path FROM info WHERE index = ?id");
command.Connection = mySQLConnection;
command.Prepare();
command.Parameters.AddWithValue("?id", id);
string result = command.ExecuteScalar().ToString();

And all I get is:
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index=1' at line 1
at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000]
at MySql.Data.MySqlClient.NativeDriver.GetResult (System.Int32& affectedRow, System.Int32& insertedId) [0x00000]

What am I doing wrong?

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>