如何在类文件中编写用于公共连接和读取器的代码 [英] How to write a code for common connection and reader in class file

查看:96
本文介绍了如何在类文件中编写用于公共连接和读取器的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将开始一个小应用程序.

我想在一个类文件中分配连接和读取器,而不是在inlne代码中使用.

另外,我不想每次都呼叫连接和阅读器.

我想维护一个班级文件.这样,每当我需要连接或读取器时,我都想调用该函数并执行存储的程序.

请给我一个带有一个小型存储过程的示例,该存储过程使用类文件进行连接和读取器进行选择/插入/删除.

I am going to start one small application.

I want to assign my connection and reader in one class file instead of using in inlne code.

Also, i don''t want to call everytime connection and reader.

I want to maintain one class file. In that, whenever i want the connection or reader just i want call that function and execute the Stored rocedure''s.

pls. give me one example with one small stored procedure with select/insert/delete using class file for connection and reader.

Thanks.

推荐答案

首先,您必须使用CRUD操作方法创建一个帮助器类,并且该类应实现ADO.NET编码并从配置文件中获取连接字符串. br/> 调用适合您的操作的方法,并处理返回类型
看看 http://srikanthtechnologies.com/blog/dotnet/adonetcrud2.aspx [ ^ ]
您会发现一个主意.
First you have to create a helper class with the CRUD operation methods and that should implement the ADO.NET coding and get the connectingstring from config file.
Call the appropriate method for your operation and as well as handle the return type
Have a look on http://srikanthtechnologies.com/blog/dotnet/adonetcrud2.aspx[^]
You will get an idea.


这篇关于如何在类文件中编写用于公共连接和读取器的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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