imports system.data imports system.data.sqlclient imports system.data.sqlclient.sqlexception public class connect private s as string private s1 as string public connect as new sqlconnection("server=yiyang;database=kderp;uid=sa;password=123") sub new() connect.open() end sub public property sql() get return s end get set(byval value) s = value end set end property 'public property table() ' get ' return s1 ' end get ' set(byval value) ' s1 = value
'end property public function retable() as datatable
dim com as new dataset()
dim ada as new sqldataadapter() dim com1 as new sqlcommand() com1.connection = connect com1.commandtext = s ada.selectcommand = com1 ada.fill(com, "t1") return com.tables(0)
end function public function exec() as integer dim i as integer
dim com as new sqlcommand() com.commandtext = s com.connection = connect i = com.executenonquery() return i end function public function retdataset(byval t as string) as dataset
dim com as new sqlcommand() com.connection = connect com.commandtext = s dim ada as new sqldataadapter() ada.selectcommand = com dim da as new dataset() ada.fill(da, t) return da end function public function retdataread() as sqldatareader
dim com as new sqlcommand() com.connection = connect com.commandtext = s return com.executereader end function end class