Click here to Skip to main content
15,906,097 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Injection Pin
Colin Angus Mackay12-Jan-08 1:32
Colin Angus Mackay12-Jan-08 1:32 
GeneralRe: SQL Injection Pin
Dave-B10-Jan-08 5:31
Dave-B10-Jan-08 5:31 
GeneralRe: SQL Injection Pin
Ritesh123410-Jan-08 9:07
Ritesh123410-Jan-08 9:07 
GeneralRe: SQL Injection Pin
Pete O'Hanlon10-Jan-08 9:55
mvePete O'Hanlon10-Jan-08 9:55 
GeneralRe: SQL Injection Pin
Dave Kreskowiak10-Jan-08 10:04
mveDave Kreskowiak10-Jan-08 10:04 
GeneralRe: SQL Injection Pin
Ritesh123411-Jan-08 3:14
Ritesh123411-Jan-08 3:14 
GeneralRe: SQL Injection Pin
Dave Kreskowiak11-Jan-08 6:42
mveDave Kreskowiak11-Jan-08 6:42 
GeneralMySql C# Stored Function Problem Pin
js800859-Jan-08 6:34
js800859-Jan-08 6:34 
I am writing a class to talk to a database I've written, the database has a stored function which takes one parameter and returns a value, it works fine when I execute it just with MySql however when I use the class I have written I get no error but the value that is returned from "ExecuteScalar" is null. The executeNoReturn Works perfectly for a stored procedure that adds some data to the DB.

Any suggestions would be appreciated




public class Parameter
{
private string mName;
private object mValue;

public Parameter(string nameIn, object valueIn)
{
name = nameIn;
value = valueIn;
}

public string name
{
get
{
return mName;
}
set
{
mName = value;
}
}

public object value
{
get
{
return mValue;
}
set
{
mValue = value;
}
}
}
public class Db
{
MySqlConnection conn;
public Db()
{
conn = new MySqlConnection("Database=test;Data Source=localhost;User Id=root;Password=alexa");
conn.Open();
}

public object executeSingleReturn(string storedName, List<parameter> parameters)
{
object returnObject = new object();
MySqlCommand command = new MySqlCommand();

command.Connection = conn;

command.CommandType = System.Data.CommandType.StoredProcedure;

command.CommandText = storedName;

foreach (Parameter a in parameters)
{
command.Parameters.AddWithValue(a.name, a.value);
}

returnObject = command.ExecuteScalar();

return returnObject;
}

public void executeNoReturn(string storedName, List<parameter> parameters)
{
MySqlCommand command = new MySqlCommand();
MySqlTransaction trans;

trans = conn.BeginTransaction();
command.Connection = conn;
command.Transaction = trans;

command.CommandType = System.Data.CommandType.StoredProcedure;

command.CommandText = storedName;

foreach (Parametera in parameters)
{
command.Parameters.AddWithValue(a.name, a.value);
}

command.UpdatedRowSource = System.Data.UpdateRowSource.None;

command.ExecuteNonQuery();

trans.Commit();
}

~Db()
{
conn.Close();
}
}
GeneralHelp in query design Pin
www.Developerof.NET9-Jan-08 5:35
www.Developerof.NET9-Jan-08 5:35 
GeneralRe: Help in query design Pin
DotNetXenon9-Jan-08 7:58
DotNetXenon9-Jan-08 7:58 
GeneralRe: Help in query design Pin
GuyThiebaut9-Jan-08 10:06
professionalGuyThiebaut9-Jan-08 10:06 
GeneralRe: Help in query design Pin
veereshIndia13-Jan-08 19:46
veereshIndia13-Jan-08 19:46 
GeneralASP.Net: Custom control problem with XML file data source Pin
Emma Burrows9-Jan-08 5:35
Emma Burrows9-Jan-08 5:35 
Generalda.Fill(second datatable) Pin
CandyMe9-Jan-08 5:20
CandyMe9-Jan-08 5:20 
GeneralRe: da.Fill(second datatable) Pin
Tom Deketelaere9-Jan-08 5:25
professionalTom Deketelaere9-Jan-08 5:25 
GeneralRe: da.Fill(second datatable) Pin
CandyMe9-Jan-08 5:32
CandyMe9-Jan-08 5:32 
GeneralRe: da.Fill(second datatable) Pin
Tom Deketelaere9-Jan-08 7:34
professionalTom Deketelaere9-Jan-08 7:34 
Questioninsert special characters into sql database Pin
swissmiss869-Jan-08 5:02
swissmiss869-Jan-08 5:02 
GeneralRe: insert special characters into sql database Pin
Ritesh12349-Jan-08 12:54
Ritesh12349-Jan-08 12:54 
Generalforce table names [modified] admin please move post to vb.net forum (thank you) Pin
Tom Deketelaere9-Jan-08 3:47
professionalTom Deketelaere9-Jan-08 3:47 
GeneralCalculation not done in SubQuery :( Pin
ha_haseebahmad9-Jan-08 0:20
ha_haseebahmad9-Jan-08 0:20 
Questionhow to define a result a in a sp Pin
jagan1238-Jan-08 23:21
jagan1238-Jan-08 23:21 
AnswerRe: how to define a result a in a sp Pin
pmarfleet9-Jan-08 0:03
pmarfleet9-Jan-08 0:03 
AnswerRe: how to define a result a in a sp Pin
Joe9-Jan-08 0:07
Joe9-Jan-08 0:07 
GeneralTwo same temp tables in two diffrent stored procedures Pin
kalam8-Jan-08 23:13
kalam8-Jan-08 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.