如何在Easy Line中选择一行查询 [英] how to do this in Easy Way Select Query in One Line
本文介绍了如何在Easy Line中选择一行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我。如何在简单的方法中执行此操作。在一行中选择查询。提前谢谢
Pls Help Me.How To do This in easy Method.Select query in one line.Thanks in advance
string qry = "select advtcountryid from advt where advtcountryid='" + countryid + "'";
string qry1 = "select agencycountryid from agency where agencycountryid='" + countryid + "'";
string qry2 = "select clientcountryid from client where clientcountryid='" + countryid + "'";
string qry3 = "select statecountryid from state where statecountryid='" + countryid + "'";
MySqlConnection con =new MySqlConnection(common.GetConnectionString());
MySqlDataReader dr = new MySqlDataReader();
MySqlTransaction tran = con.BeginTransaction(IsolationLevel.ReadCommitted);
MySqlCommand cmd = new MySqlCommand(qry, con, tran);
cmd.Transaction = tran;
dr = cmd.ExecuteReader();
dr.Read();
cmd.CommandText = qry1;
cmd.ExecuteNonQuery();
cmd.CommandText = qry2;
cmd.ExecuteNonQuery();
cmd.CommandText = qry3;
cmd.ExecuteNonQuery();
推荐答案
使用存储过程放置所有这些查询并从代码中调用此单个SP 。
以下会有所帮助:
MSDN :如何:使用Visual C#.NET在ASP.NET中调用SQL Server存储过程 [ ^ ]
MSDN:如何:通过以下方式调用参数化存储过程使用ADO.NET和Visual C#.NET [ ^ ]
ADO.NET:使用存储过程 [ ^ ]
MSDN:CREATE PROCEDURE(Transact-SQL) [ ^ ]
Use stored procedure where you put all these queries and call this single SP from code.
Following would help:
MSDN: HOW TO: Call SQL Server Stored Procedures in ASP.NET by Using Visual C# .NET[^]
MSDN: HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET[^]
ADO.NET : Using Stored Procedures[^]
MSDN: CREATE PROCEDURE (Transact-SQL)[^]
你做过像这样的查询........
u have do somthing like this query........
string qry=select a.advtcountryid ,ag.agencycountryid,c.clientcountryid ,s.statecountryid from agency a,agency ag,client c,state s
where a.advtcountryid='" + countryid + "' and ag.agencycountryid='" + countryid + "' and c.clientcountryid='" + countryid + "' and s.countryid + ='" + countryid + "'";
这篇关于如何在Easy Line中选择一行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文