编写类库的有意思的问题!!大家贡献!!(走过路过千万不要错过啊!!超级经典)
azyue 2003-10-15 03:45:16 本人编写类库时想编写特性,使调用这移动到方法或属性时可以显示提示
查了好几本书和框架没有所的,请有经验的给点提示!!谢谢。
没有经验的竟请留意以下!!!!!!!!!!!::::::::::·!《》《》《》《》
<attribute()……??????
恩?不是吧,各位仁兄再努力给个提示好了啊。
要不就当成开发包装类库的啊论吧,我献给点离子,希望不要辜负啊!!
Imports System.Data.SqlClient
Imports System.Attribute
Imports System.ComponentModel
Imports System.Reflection
Public Interface Isql
End Interface
Namespace ClsOpSql '<AssemblyDescription("adsfasdf")> _
<AttributeUsage(AttributeTargets.Assembly)> _
Public Class ExcuteIdle
Dim cn As SqlConnection
<Browsable(True) > _
Sub New(ByVal strconnection As String)
cn = New SqlConnection(strconnection)
End Sub
'<Obsolete("fdsssssssss")> _
<Description("asdfsdafFDS")> _
Public Property az() As String
Get
End Get
Set(ByVal Value As String)
End Set
End Property
<Description("asdfdfs")> _
Public Function backds(ByVal strselect As String) As DataSet '返回dataset
Dim drt As SqlDataAdapter
Dim dstemp As DataSet
Try
cn.Open()
drt = New SqlDataAdapter(strselect, cn)
dstemp = New DataSet()
drt.Fill(dstemp)
Return dstemp
Finally
cn.Close()
End Try
End Function
Public Function BackRecord(ByVal strselect As String) '返回单条记录
Dim cm As New SqlCommand(strselect, cn)
Dim str As String
'Dim dr As SqlDataReader
Try
cn.Open()
'dr = cm.ExecuteReader()
'While dr.Read
' str = dr.Item(strfeild)
'End While
str = CStr(cm.ExecuteScalar())
Return str
Finally
cn.Close()
End Try
End Function
Public Function BackRecord(ByVal strselect As String, ByVal strfeild As String) As String '重载 BackRecordset
Dim cm As New SqlCommand(strselect, cn)
Dim str As String
Dim dr As SqlDataReader
Try
cn.Open()
dr = cm.ExecuteReader()
While dr.Read
str = dr.Item(strfeild)
End While
'str = CStr(cm.ExecuteScalar())
Return str
Finally
dr.Close()
cn.Close()
End Try
End Function
Public Function excucommand(ByVal strsqlexcu As String) As Boolean '运行sql命令
Dim cm As SqlCommand
Try
cn.Open()
cm = New SqlCommand(strsqlexcu, cn)
cm.ExecuteNonQuery()
Return True
Finally
cn.Close()
End Try
End Function
Public Function Trainexcu(ByVal str1 As String, ByVal str2 As String) As Boolean '进行事务处理
Dim train As SqlTransaction
Dim cm1 As New SqlCommand(str1, cn)
Dim cm2 As New SqlCommand(str2, cn)
cn.Open()
train = cn.BeginTransaction()
cm1.Transaction = train
cm2.Transaction = train
Try
cm1.ExecuteNonQuery()
cm2.ExecuteNonQuery()
train.Commit()
Return True
Catch e As SqlException
train.Rollback()
Throw e
Finally
cn.Close()
End Try
End Function
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
End Namespace