18 questions
0
votes
1
answer
120
views
MySqlParameter with float value of 0.0
I constructed a MySqlParameter with MySqlParameter tmp1 = new MySqlParameter("?tmp1", 0.0); and when executing the corresponding insert query received the error message that the respective column ...
1
vote
2
answers
380
views
sqlcommand c# method with sql paramather
I have this method, which I have in the base class that helps me to select anything from the children classes and also to reduce code repetition. The problem is when I call it I get an error which is ...
0
votes
0
answers
553
views
C# MySql - String.Format vs MySql Parameters
I've been looking for an answer to my question, but i cannot find it, so here it is:
Between String.Format and MySql Parameters, what is the best practice in terms of creating a query for the ...
1
vote
1
answer
148
views
Excepion with MysqlCommand and "SET @q:" variable C#?
i have this code:
using (MySql.Data.MySqlClient.MySqlConnection cn = new
MySql.Data.MySqlClient.MySqlConnection(
Properties.Settings.Default.CONNNConnectionString))
{
...
5
votes
3
answers
4k
views
Why does MySqlParameter Add parameter as 0 convert to null
I'm adding a parameter to be called with a MySQL stored procedure like
List<MySqlParameter> MyParams = new List<MySqlParameter>();
MyParams.Add(new MySqlParameter("MyId", 0));
But for ...
4
votes
1
answer
2k
views
C# with MySql and Unicode characters
My problem is when using C# and MySQL database to save some records by sending parameters.
Although i have already set the charset as Utf-8 and i can see the unicode characters correctly, the problem ...
0
votes
1
answer
794
views
C# MySqlParameter Wildcard Search
I am trying to have a function that can search for an item (in this case, a motherboard) in a database when given parameters, but I want to be able to get all motherboards if no parameters are given.
...
2
votes
1
answer
3k
views
MySqlParameter as TableName
I want to use MySqlParameter to pass tableName into query (to prevent slq injections)
MySqlCommand cmd = new MySqlCommand("select * from @table"), cn)
cmd.Parameters.AddWithValue("@table",TableName);
...
22
votes
10
answers
22k
views
Add List<int> to a mysql parameter
I have this question about the MySqlParameter from the .NET connector.
I have this query:
SELECT * FROM table WHERE id IN (@parameter)
And the MySqlParameter is:
intArray = new List<int>(){1,...
0
votes
1
answer
4k
views
Parameterized MySql INSERT query not having right parameters value
I'm trying to do a basic insert statement using a parameterized query. My problem is whatever the syntax I'm using it seems like the query is being done with all parameters set to null instead of ...
0
votes
1
answer
3k
views
How to use MySQLparameter array in Mysqlcommand to add with command
I have a mysqlcommand and mysqlparameter array []
MySqlParameter[] param = new MySqlParameter[]{
// params here
};
Now I want to set the command parameter for this array. How I can do ...
2
votes
1
answer
2k
views
Difference between adding MySql Parameters with Add() and AddWithValue()
According to MySql in this document C.7.9.6. Changes in MySQL Connector/NET 5.0.5 (07 March 2007):
Added MySqlParameterCollection.AddWithValue and marked the Add(name, value) method as obsolete.
I'...
0
votes
2
answers
3k
views
The SqlParameterCollection only accepts non-null SqlParameter type objects, not MySqlParameter objects
I have created a method that will insert any exceptions thrown into a table on "ExceptionLog" on MySql server.
ExceptionLog Table format
idExceptionLog int (AI)
User (varchar 45)
...
5
votes
2
answers
3k
views
Can i use a parameter multiple times in the same query?
i was wondering, can a parameter be used more then once in the same query, like this :
MySqlParameter oPar0 = new MySqlParameter("e164", MySqlDbType.String);
oPar0.Value = user.E164;
string sSQL0 = "...
9
votes
8
answers
14k
views
C# and MySQL .NET Connector - Any way of preventing SQL Injection attacks in a generic class?
My idea is to create some generic classes for Insert/Update/Select via a C# (3.5) Winforms app talking with a MySQL database via MySQL .NET Connector 6.2.2.
For example:
public void Insert(string ...
1
vote
1
answer
791
views
mySQL :syntax using in C#
I am using in C# MYsql .I have query that works if I run on MySql Workbench ,but in C# it does not return any value also does not give ant error too.There is only one different using on Mysql I use ...
6
votes
1
answer
11k
views
C# MySqlParameter problem
(int) faultsGroup is 0 or 1 but i always get this error: Column 'FaultGroup' cannot be null
Does anyone tell me why? Syntax looks ok.
MySqlCommand cmdAdd = new MySqlCommand("INSERT INTO Faults (" +
...
2
votes
3
answers
1k
views
How do I conditionally set a column to its default value with MySqlParameter?
I have a table in a MySql database that stores user accounts. One of the columns, expires, stores an expiration date but defaults to NULL. I need to be able to remove an expiration date and set it ...