如何将sql查询发送到类文件 [英] how to send sql query to class file

查看:124
本文介绍了如何将sql查询发送到类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在App_Code文件夹中有Class1.cs类文件。现在我处于这样一种情况,我必须在这个类中加载Defalt.aspx页面时发送sql查询..我在Class1.cs文件中有一个名为query1的变量..如何在类文件中发送查询...所以我可以在cs文件中使用该查询...帮助将被赞赏...

i have Class1.cs class file in App_Code folder. Now i am in a situation that i have to send sql query in this class on load of the Defalt.aspx page.. i have a variable named query1 in Class1.cs file.. how to send query in class file... so that i can use that query in cs file... help will be appreciated...

推荐答案

根据我的理解。您可以直接在Default.aspx.cs中调用Class1名称,并可以使用Class1的所有函数。但是你的问题在加载Default.aspx时在此类中发送sql查询
As per my understanding. You can directly call your Class1 name in Default.aspx.cs and can use all functions of Class1. But there is no clarity with your question "send sql query in this class on load of the Default.aspx"


声明查询变量为静态,如public static strQuery =.... ;你的class1.cs页面中的


并在默认页面中调用此变量,如class1.strQuer。
Declare Query variable as Static like public Static strQuery="...." ;

in your class1.cs page and call this variable in default page like class1.strQuer .


假设你需要在课堂上发送查询,比如



string query =Sql Query;



你需要发送这个查询类变量query1如下所示



使类对象像





Class1 clas = new Class1();



然后确定你的价值



clas.query1 =Sql查询或引用变量
suppose you need to send query in class like

string query="Sql Query";

you need to send this query to class variable query1 do as below

make object of class like


Class1 clas=new Class1();

then assing your value

clas.query1="Sql Query or reference Variable"


这篇关于如何将sql查询发送到类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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