473,725 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple task works when MS SQL Server is the backend but not when MySQL is the backend.

Ted
In MS SQL I used the following to create a stored procedure.

USE AdventureWorks;
GO
IF OBJECT_ID ( 'HumanResources .usp_My_Search' , 'P' ) IS NOT NULL
DROP PROCEDURE HumanResources. usp_My_Search;
GO
CREATE PROCEDURE HumanResources. usp_My_Search
@searchstring varchar(40)
AS
SELECT LastName, FirstName, JobTitle, Department
FROM HumanResources. vEmployeeDepart ment
WHERE LastName LIKE @searchstring;
GO
HumanResources. usp_My_Search '%man%';
GO

Simple, obvious, and it works. Of course, if you have MS SQL Server
2005, you will recognize the AdventureWorks database.

Here is the whole webpage (the test project was created as a website):

<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$
ConnectionStrin gs:AdventureWor ksConnectionStr ing2 %>"
SelectCommand=" EXECUTE HumanResources. usp_My_Search @p1">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Text Box1" Name="p1"
PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>

</div>
<asp:DropDownLi st ID="DropDownLis t1" runat="server"
DataSourceID="S qlDataSource1"
DataTextField=" LastName" DataValueField= "LastName">
</asp:DropDownLis t>
<asp:TextBox ID="TextBox1" runat="server"> %man</asp:TextBox>
</form>
</body>
</html>
Everything in this trivially simple test works fine. If I change the
content of TextBox1, the items in DropDownList1 are changed
immediately. Perfect. Well almost. I haven't yet figured out how to
programmaticall y change the value submitted to the stored procedure so
that the user does not have to enter the leading or trailing '%'
character, but that is a minor nuisance.

But all is NOT rosy when I use MySQL instead of MS SQL.

Here is the function I created in MySQL:

CREATE PROCEDURE `sp_find_food`(
IN search_string varchar(255)
)
BEGIN
DECLARE ss VARCHAR(257);
SET ss = CONCAT('%',sear ch_string,'%');
SELECT NDB_No,Long_Des c FROM food_des WHERE Long_Desc LIKE ss;
END

The similarity with my MS SQL Server stored procedure is obvious! And
here is the markup that is supposed to exercise it:

<LoggedInTempla te>
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:sr19Connecti onString %>"
ProviderName="< %$
ConnectionStrin gs:sr19Connecti onString.Provid erName %>"
SelectCommand=" CALL sp_find_food('@ ss')">
<SelectParamete rs>
<asp:ControlPar ameter
ControlID="sear ch_string" Name="@ss" PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:sr19Connecti onString %>"
ProviderName="< %$
ConnectionStrin gs:sr19Connecti onString.Provid erName %>"
SelectCommand=" SELECT NDB_No,Long_Des c FROM sr19.food_des WHERE
Long_Desc LIKE '@ss'">
<SelectParamete rs>
<asp:ControlPar ameter
ControlID="sear ch_string" Name="@ss" PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>
<table width=100%>
<tr>
<td>Hello <asp:LoginNam e runat="server" /></
td>
<td align="right">< asp:LoginStatus
ID="LoginStatus 1" runat="server" /></td>
</tr>
</table>
<a href="ADProfile .aspx">Create your profile</a>&nbsp;
<table width=100%>
<tr>
<td style="width: 30%">Enter part of a food
name</td>
<td style="width: 70%">
<asp:TextBox ID="search_stri ng"
runat="server" AutoPostBack="T rue"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 30%">select a food</td><td
style="width: 70%">
<asp:DropDownLi st ID="DropDownLis t1"
runat="server" AutoPostBack="T rue" DataSourceID="S qlDataSource1"
DataTextField=" Long_Desc"
DataValueField= "NDB_No" Width="100%">
</asp:DropDownLis t></td>
</tr>
<tr>
<td style="width: 30%">select a food</td>
<td style="width: 70%">
<asp:DropDownLi st ID="DropDownLis t2"
runat="server" AutoPostBack="T rue" DataSourceID="S qlDataSource2"
DataTextField=" Long_Desc"
DataValueField= "NDB_No" Width="100%">
</asp:DropDownLis t>
</td>
</tr>
</table>
</LoggedInTemplat e>

Again the parallel is obvious. But neither of these dropdownlists is
ever populated! Since the second SQLDataSource uses a simple SELECT
rather than my stored procedure, and it does not get populated either,
my hunch is that there is something wrong with the MySQL .NET
connector (MySQL Connector/Net 5.0.3). IS anyone using MySQL and this
connector successfully? Can what I have done be fixed.

How can I examine whatever is returned by the database, so I can find
out where the problem is happening? I am aware that I can write code
in the C# file corresponding to the page, but when I try, I can't seem
to access the controls on the page. :-( This makes it hard to figure
out whether the problem is with the database back end, the connector,
or the ASP.NET page.

Any help would be appreciated.

Thanks

Ted

Feb 20 '07 #1
1 1828
Ted
Further information!

I find I can get this connector to connect database tables to ASP.NET
datasources, for display in an ASP.NET gridview. Even pagination and
support for sorting appear to work. Where it fails to work properly
is with statements to execute stored procedures and parameterized
SELECT statements.

Oh well, at least I can get MySQL to work with my Java programs and
JDBC.

Cheers

Ted

Feb 22 '07 #2

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

Similar topics

0
603
by: Alex Glaros | last post by:
I need help on my basic table connection syntaxt using PHP. I call the php from a web browser url_name_goes_here/test.php. The database name is tennis and the user name is tennis. If I type the commands directly from the MySQL> mode, my access works fine (see example 1 below). But when I try to access the table from PHP, I have a syntaxt problem (see example 2 below). Can anyone please type up the correct PHP syntaxt for me? The...
3
2216
by: Chuck | last post by:
Here is my setup. Netgear Router with a webserver and database server NAT'd behind the firewall. Microsoft Windows 2000, IIS 5 - Web Server Microsoft Windows 2000, MySQL - Database Server What I would like to have is a web application served up off my WS (web server) and that application access my DS (db server) without
0
1804
by: Andreas Reuleaux | last post by:
What works for me with mysql 3.23.49 of Debian GNU/Linux (Woody), does not any more with mysql 3.23.56 of fink (current-stable, for fink cf. fink.sf.net) - I am not sure, if this problem is caused by the mysql version (some security changes between .49 and .56) or by the fink configuration - I might ask at the fink-users list later. I am trying to create a database and a mysql user with privileges to use it - a rather simple thing to...
0
1458
by: Lloyd Dobbler | last post by:
Hi, I'm not that up on SQL as a whole as I've concentrated mainly on frontend and most of the DB backend work I've done has been with "Access" as that's all the site needed. I have however worked with SQL Server 2000 a little and now I'm trying to migrate to MySQL. I understand that views are not supported in MySQL as yet and was curious to know if there is a workaround this using VBScript? My VBScript coding is a bit of a mish-mash...
14
2862
by: MLH | last post by:
I have a friend with a database application on a web server. He has invited me to attach to it so I can extract data from it periodically. I have a few questions... 1) I have a DSL connection to my ISP and I think my buddy has one too. Can I establish an ODBC connection to his data- base? What information would I need to gather that would allow us to do this? 2) Can I "turn the connection on & off" at will? Are there any
4
1498
by: ItNerd | last post by:
Someone PLEASE HELP ME!!!!! All I want to do is a simple postback and grab the value from a textbox on clicking a linkbutton like below, but the value is not writing to the screen. I am frustrated with this seemingly simple task. I have enabledviewstate=true on the @Page directive, and I tried using onclick on the linkbutton, nothing. I know the event is firing because I can set the value to a hardcoded string and get it to show. In...
7
3772
by: Ivan Marsh | last post by:
Hey Folks, I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I understand it I need a PHP script that pulls the query and dumps the data into XML format, that is called by triggering a javascript event that reads that file with XMLhttprequest.
6
2036
by: Jim M | last post by:
I've been distributing a fairly mature, very specific MS Access application to end users in small offices of colleges for several years now. This is a part-time venture and low volume operation- this is somewhat of a hobby for me. Many of my end users are computer phobic and get little support from their IT departments. It is a split database so the datafile gets put on the file server and the 3 different front ends get put on each local...
8
1935
by: rdemyan via AccessMonster.com | last post by:
Anyone have any ideas on how to determine when the back-end file (containing only tables) has been updated with new data. The date/time of the file won't work because it gets updated to the current date/time when the back-end file is compacted. I'm just looking for an easy way to determine when there has been a change to data in any table in the back-end file. Maybe something is updated in one of the system tables??
0
8874
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9393
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9092
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8072
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6695
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4506
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3212
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.