如何在ADO.NET中返回multipule行数据 [英] How to return multipule rows data in ADO.NET

查看:126
本文介绍了如何在ADO.NET中返回multipule行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好亲爱的

我在Asp.net中创建一个Web方法C#

  public  静态 字符串 Getdata( string  Id)
{
string SQL = select * from testtable,其中UserId =' + Id + ';
DataTable DATA = new DataTable();
SqlDataAdapter DTA = new SqlDataAdapter(SQL,cnnx);
DTA.Fill(DATA);
if (DATA.Rows.Count > 0
{






}
return ;



这是我的代码

现在我想返回所有行值以获得ajax成功的价值

 \< script> 
$( document )。ready( function (){
$(< span class =code-string> #Btnclick)。点击( function (){
$ .ajax({
type: POST
url: WebForm1.aspx / Getdata
data: {'Id':' + $( #textid)。val()+ '}
数据类型: JSON
contentType: a pplication / JSON; charset = ut-8
成功:功能(数据)
{
alert(data.d) ;

},
错误: function (){
alert( 错误);
}


});

});



});
< / script>





我尝试过:



获取所有行值并返回ajax中的值

解决方案

document )。ready( function (){


#Btnclick)。click( function (){


.ajax({
type: < span class =code-string> POST,
url: WebForm1.aspx / Getdata
数据: {'Id':' +

Hello Dear
am create a web method in Asp.net C#

public static string Getdata(string Id)
       {
           string SQL = "select * from testtable where UserId='" + Id + "'";
           DataTable DATA = new DataTable();
           SqlDataAdapter DTA = new SqlDataAdapter(SQL, cnnx);
           DTA.Fill(DATA);
           if (DATA.Rows.Count > 0)
           {






           }
           return "";


This is my code
now i want to return all rows value to get value in ajax success

\  <script>
        $(document).ready(function () {
            $("#Btnclick").click(function () {
                $.ajax({
                    type: "POST",
                    url: "WebForm1.aspx/Getdata",
                    data: "{'Id':'" + $("#textid").val() + "'}",
                    datatype: "JSON",
                    contentType: "application/json; charset=ut-8",
                    success:function(data)
                    {
                        alert(data.d);
                       
                    },
                    error: function () {
                        alert("error");
                    }
                   

                });

            });



        });
    </script>



What I have tried:

Get all rows value and return value in ajax

解决方案

(document).ready(function () {


("#Btnclick").click(function () {


.ajax({ type: "POST", url: "WebForm1.aspx/Getdata", data: "{'Id':'" +


这篇关于如何在ADO.NET中返回multipule行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆