WebService e SQL [C#]

venerdì 07 marzo 2008 - 12.06

piero87 Profilo | Junior Member

Salve a tutti!
Vi espongo il mio problema: ho provato a fare un webservice con il seguente codice, ma non mi restituisce il dataAdapter...credo allora che non sia permesso fare questa operazione (cioè restituire un dataAdapter con un webservice): questo visto il messaggio di errore che mi da [allegato].
In pratica vorrei avere la possibilità di riempire un DataGrid passando appunto da un WebService.
In pratica vorrei riuscire a riempire un datagrid passando da un webservice...come posso fare? posso partire dal codice postato o devo farne uno diverso? che possibilità ho?
Utilizzo IIS con Win Professional SP 2 , Visual studio 2003 con c#, MySQLServer 2005.

Grazie

<%@ WebService language="C#" class="ricerca" %> using System; using System.Web.Services; using System.Xml.Serialization; using MySql.Data; using MySql.Data.MySqlClient; using System.Data; [WebService(Namespace="http://localhost")] public class ricerca : WebService { [WebMethod] public MySqlDataAdapter Search(string a, string b) { string connStr="Database=prova; Data Source=localhost;User Id=root; Password="; MySqlConnection myConn = new MySqlConnection(connStr); string query = "SELECT * FROM contatti WHERE" +a+ "="+b+";"; MySqlCommand cmd = new MySqlCommand(query, myConn); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = cmd; DataTable tab = new DataTable(); myConn.Open(); myAdapter.Fill(tab); myConn.Close(); return myAdapter; } }


Piero




ok, scusate...
http://support.microsoft.com/kb/306134
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5