473,402 Members | 2,072 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,402 software developers and data experts.

jQuery and mysql problem

Paul Johnson
Hi,

Not sure why this hasn't appeared... anyhoo....

I've hit a bit of a problem with a jQuery and a webservice. The webservice is in VB.NET and it's been quite a while since I last did anything in VB or a webservice.

Thing is, I'm not sure if the problem is in the query or in the code. All I get when I run is a button (which is correct) and after I click it, I get an error 500 - which doesn't really help.

The query (below) has security issues which I'm completely aware of - but as it's for my own use, that's ok - I can tidy that up at some point if I decide to use it.

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3.     <title>A quick and dirty hack</title>
  4.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
  5.     <script type="text/javascript">
  6.         $(document).ready(function() {
  7.             $("#btnMore").click(function() {
  8.                 $.ajax({
  9.                         type:"POST",
  10.                         contentType: "application/json; charset=utf-8",
  11.                         url: "WebService1.asmx/GetData",
  12.                         data: "{'localhost', 'root', '', 'Table1', {'SELECT','Name','where','age > 25','and','hometown == Liverpool'}, {'','','',''}",
  13.                         success: onSuccess,
  14.                         error: onError
  15.                       });
  16.             });
  17.         });
  18.  
  19.         function onSuccess(result)
  20.         {
  21.             $("#datalist").empty()
  22.             var strings = result.d;
  23.             for (var i = 0; i < strings.length; ++i)
  24.                 $("#datalist").append("<li>" + strings[i] + "</li>");
  25.         }
  26.  
  27.         function onError(result)
  28.         {
  29.             alert(result.status + ": " + result.statusText);
  30.         }
  31.  
  32.     </script>
  33. </head>
  34.  
I have a feeling that it's down to what I'm passing into the webservice rather than the webservice

Expand|Select|Wrap|Line Numbers
  1. <System.Web.Script.Services.ScriptService()> _
  2. <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
  3. <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
  4. <ToolboxItem(False)> _
  5. Public Class WebService1
  6.     Inherits System.Web.Services.WebService
  7.  
  8.     <WebMethod()> _
  9.     Public Function GetData(ByVal server As String, ByVal uid As String, ByVal pw As String, _
  10.                             ByVal db As String, ByVal cmds As ArrayList, ByVal tbl As ArrayList) As DataSet
  11.         Dim connection As SqlConnection
  12.         Dim data As New DataSet("GetDataSet")
  13.         Dim constr As String = "server=" + server + "; uid=" + uid + "; pwd=" + pw + "; database=" + db
  14.         Try
  15.             connection = New SqlConnection(constr)
  16.             connection.Open()
  17.             For i = 0 To cmds.Count
  18.                 If (Not (cmds(i).ToString()).StartsWith(("SELECT" Or "Select"))) Then
  19.                     Throw MySQLException("The SQL command must start with SELECT or Select")
  20.                 End If
  21.                 Dim command As New SqlCommand
  22.                 command.Connection = connection
  23.                 command.CommandText = cmds(i).ToString()
  24.                 Dim dataadapter As New SqlDataAdapter
  25.                 dataadapter.SelectCommand = command
  26.                 dataadapter.TableMappings.Add("Table", tbl(i).ToString())
  27.                 dataadapter.Fill(data)
  28.                 Return data
  29.             Next
  30.  
  31.         Catch ex As System.Data.SqlClient.SqlException
  32.             Throw
  33.         End Try
  34.         connection.Close()
  35.     End Function
  36.  
  37.     Private Function MySQLException(ByVal p1 As String) As Exception
  38.         Throw New NotImplementedException
  39.     End Function
  40.  
  41. End Class
  42.  
Am I correct in thinking that I'm just passing things in correctly or is there something else I've missed?

Thanks

Paul
Oct 29 '10 #1
6 2180
Frinavale
9,735 Expert Mod 8TB
A 500 error messages means that there was a general error that occurred on the server while processing. If you have access to the Windows Event logs on the server where your application is hosted I would check them for anything that might explain what is causing the 500 error.

-Frinny
Oct 29 '10 #2
It's being done through VS2010 via localhost. Not sure where to look for it under Win7 (normally I use Linux)
Oct 29 '10 #3
Frinavale
9,735 Expert Mod 8TB
Go to
  • Control Panel
  • Administrative Tools
  • Event Viewer

This will let you view the Windows Event logs. Expand the "Windows Logs" tree and go through the Event Logs under that tree to view any events or errors that Windows has encountered. Look for anything related to IIS, or ASP.NET or your application...

-Frinny
Oct 29 '10 #4
Frinavale
9,735 Expert Mod 8TB
Just curious, why aren't you using the built in debugging capabilities of Visual Studio 2010?
Oct 29 '10 #5
I'm new to VS2010. If I set a breakpoint in the VB it comes up with a page that says Webservice1 and shows the method available. If I click on the method is comes up with that "the test form is only available for methods with primitive types as parameters" followed by some soap 1.1 stuff

By the looks of it, passing ArrayLists are a no-no, but looking at http://www.c-sharpcorner.com/UploadF...ebService.aspx, arraylists are fine to pass.

HELP - which one is right or is it a language specific problem? (the above is in C#, mine is in VB)
Oct 29 '10 #6
Not really used to VS2010, but it's getting me further.

If I put a breakpoint in the VB I get a screen saying WebService1 which means (to me) that it's sending to VB ok. If I click on the GetData method, it comes up with a message that only primitives are allowed to be passed in, so I'm guessing that means ArrayLists are right out.

However, googling around has brought me to http://www.c-sharpcorner.com/UploadF...ebService.aspx which suggests that passing ArrayLists to a webservice is ok.

Have I hit a VB specific problem or am I missing something?

Paul
Oct 29 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
2
by: Erik R.N. | last post by:
Hi 2 years ago i managed to set up my PC to be able to upload semicolonseparated database-files to my mysql-database on a webhost-server which also contain my website (from where one can do search...
1
by: Dominik Szczurek | last post by:
Hello to anyone who is tring to help me :-) As I was writed in the topic I have problem when somone input 0 value in the form. PHP is losting this value when it try to write it to mySQL. I have...
2
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on...
1
by: Henry16 | last post by:
Hi. Impossible to create a database using MySQL !!! Message : #1006 - Can't create database 'boby'. (errno: 13) I was told : chown mysql.mysql -R /var/lib/mysql chmod 750 -R /var/lib/mysql...
0
by: edward_sanders | last post by:
Hi, This is a newbie question. I am using a text for learning php/mysql. I am using PHP 5.2.x and mysql 5. The example is that of a mysql database of jokes. Before we get to joins there is a...
5
by: suma | last post by:
hi to all plaese help me i have same problem when download the phpdev and phptriad i cant connect to mysql when click the MyAdmin apear this messege in the page 'Warning: MySQL Connection...
2
by: Bobby Edward | last post by:
I am using VS 2008 SP1, ASP.NET 3.5, VB.NET, MySQL (latest version). I created a new dataset using VS. In the ds I have a users table. I let it create the "Fill, GetData" functions in the...
1
by: DarkGiank | last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.