473,327 Members | 1,979 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,327 software developers and data experts.

Fetching data from MySQL db

I have two simple function in PHP that I want to convert to C# -

function Doit($enc_user_name, $enc_password)
{
$result = $mysqli->query("call
sp_userAuth('$enc_user_name','$enc_password')");

if (mysqli_num_rows($result) != 0)
{
$data = $result->fetch_array(MYSQLI_BOTH);
return $data;
}
return null;
}

function JustDoit($user_id, $session_id)
{
$result = $mysqli->query("call
sp_userMultiLogin('$user_id', $seesion_id)");

if (mysqli_num_rows($result) != 0)
{
$row = $result->fetch_array(MYSQLI_BOTH);
return $row['session_id'];
}
return null ;
}
Can anyone show me how I may port them to C#?. I am using the OleDbData
Provider to access the MySQL database. The examples you provide are
really to help me no how to :

1). Pass parameters to a stored procedure (in the PHP code above, all
parameters are strings - apart from user_id, which maps to a C# uint)

2). Return a dataset back to C#

3). Return the value for a specific column back to C#
Dec 28 '07 #1
1 3051
Frank,

Well, if you are using the OleDb providers for .NET, then you would do
these things the way that you would for any other data access. This
involves defining your parameterized command, adding/populating the
parameters on your command, executing a reader on it (or, assigning it to a
data adapter if you want to fill a dataset).

You also might want to look at the .NET connector for MySql:

http://dev.mysql.com/downloads/connector/net/5.1.html

As it follows the pattern for data access in .NET (and is probably more
efficient, in that is accessing the source natively, as opposed to going
through an indirection layer like OleDb).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Frank Moyles" <fg******@nospam.comwrote in message
news:3q******************************@bt.com...
>I have two simple function in PHP that I want to convert to C# -

function Doit($enc_user_name, $enc_password)
{
$result = $mysqli->query("call
sp_userAuth('$enc_user_name','$enc_password')");

if (mysqli_num_rows($result) != 0)
{
$data = $result->fetch_array(MYSQLI_BOTH);
return $data;
} return null;
}

function JustDoit($user_id, $session_id)
{
$result = $mysqli->query("call sp_userMultiLogin('$user_id',
$seesion_id)");
if (mysqli_num_rows($result) != 0)
{
$row = $result->fetch_array(MYSQLI_BOTH);
return $row['session_id'];
} return null ; }
Can anyone show me how I may port them to C#?. I am using the OleDbData
Provider to access the MySQL database. The examples you provide are really
to help me no how to :

1). Pass parameters to a stored procedure (in the PHP code above, all
parameters are strings - apart from user_id, which maps to a C# uint)

2). Return a dataset back to C#

3). Return the value for a specific column back to C#

Dec 31 '07 #2

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

Similar topics

1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
7
by: Mark | last post by:
let's say i have a table in my database, with only one column. all i want to do is retrieve a list of the entries.. i could do it like this $result = mysql_query("SELECT * FROM t1"); while( $x =...
9
by: warezguy05 | last post by:
Hello I'm experiencing a problem; I've written a small script where volunteers can be booked for work-activities at a festival. The festival has 5 different departments so i've created a...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
1
by: Bhavesh | last post by:
Hi Bruce, Thanks For Reply. U were right, Needed to pass string , but also need to pass size of Data( instead of 16, passed actual length of data). So that worked for me & didn't get any...
2
by: SunshineInTheRain | last post by:
I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some...
7
by: FeelLikeANut | last post by:
I'm using the example on the following page for selecting and fetching a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/...
11
donilourdu
by: donilourdu | last post by:
hi, I am trying to retrive data from MYSQL database.I am using limit to fetch the data.It will fetch two rows instead of fetching ten rows.But when i try to debug it fetches eight rows instead...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.