在VB写的DLL中返回RECORDSET,但是在ASP中不能用!

yushiro 2003-09-11 04:11:26
VB:
Public Function GenerateReportSQL(ByVal UserId As Long, ByVal ReportID As Long, ByVal ExecuteSQL As Long) As ADODB.Recordset
......
Set GenerateReportSQL = cmd.Execute
.....

asp:
set app = CreateObject("testreport.application")
set ors = app.GenerateReportSQL(clng(iUserId), clng(iReportId), 1)
set app = nothing
response.write ors.Fields.count

结果显示0,但是结果集有内容。
...全文
33 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yushiro 2003-09-15
  • 打赏
  • 举报
回复
to dddd8888:
VB中的函数申明时,加入NEW就除错(至少在VB写的DLL中是这样)。

Set GenerateReportSQL = new recordset我去试试。

GenerateReportSQL = cmd.execute应该不可以,对象的赋值必须要用SET


to Suron128(辰龍) :
VB的代码是在VB中的,不是在ASP页面中。
Sunron128 2003-09-12
  • 打赏
  • 举报
回复
VB:
Public Function GenerateReportSQL(ByVal UserId As Long, ByVal ReportID As Long, ByVal ExecuteSQL As Long) 'As ADODB.Recordset '注释掉,在ASP中无须使用
......
GenerateReportSQL.CursorLocation = 3 '表示在客户端使用
Set GenerateReportSQL = cmd.Execute
.....

asp:
set app = CreateObject("testreport.application")
set ors = app.GenerateReportSQL(clng(iUserId), clng(iReportId), 1)
set app = nothing
response.write ors.Fields.count
dddd8888 2003-09-12
  • 打赏
  • 举报
回复
是不是这样
Public Function GenerateReportSQL(ByVal UserId As Long, ByVal ReportID As Long, ByVal ExecuteSQL As Long) As new ADODB.Recordset

或者
Set GenerateReportSQL = new recordset
GenerateReportSQL = cmd.execute
yuanxy 2003-09-11
  • 打赏
  • 举报
回复
我也想知道
1,animate.zipThis ActiveX DLL (Source Included) shows how to create animated dialogs in VB5. 2,MetricConversionDLL.zip34 Metric conversion routines in a VB5 DLL. Callible directly or just call the nice front end.3,ControlP.zipWith help of this OCX you can call 39 control panels in windows!4,RemBuilderplus.zipActiveX that allows the ability to add comment blocks with ease.5,VertMenu.zipThis is a free active ocx with full source code for a vertical menu with the look and feel of Outlook 97. 6,dm10e.zipDevMailer adds SMTP email sending abilities to your VB, ASP, VBA, Delphi, or Perl program in just seconds! Features 7,HideAway.zipAn alignable tool bar which can be hidden. Also includes smooth scrolling for hiding/unhiding.8,tlsGUI.zipTILISOFT GUI ActiveX Controls - ImageLabel, ScrollPanel, SplitPanel, Brief9,recordsetEng.zipThis application shows how a DLLActiveX queries a Database and returns the recordset to the Standard EXE application.10,THtml.ZipShow Page Title for file selected with ".HTM" or ".ASP" extension11,Fancy_Button.zipFancy Button12,TransFX.zipTransitionFX is an ActiveX control that allows you to make professional quality slide shows, picture presentations or screen savers13,Roman.zipThis activeX control convert Decimal numbers to Roman numerals and back 14,pgBar.zipCarrick Progress Bar 1.0 - replacement for standard progress bar with customizable colors and styles15,JPGMaker.zipJPGMaker is an ActiveX control designed to compress bitmap images and save them in JPG format16,pictuner.zipPicTuner is an ActiveX control designed to adjust contrast, brightness and color balance of bitmap images. It supports the following file formats: *.jpg, *.bmp, *.dib. 17,Hyperlink.zipHyperlink ActiveX control allows you to include hypertext links on your forms18,shortcut.zipShortcut is an ActiveX control designed to create shortcuts to programs and documents and place them on windows desktop.19,PicOpener.zipPicOpener is an ActiveX control that allows you to read image files in over 50 formats and convert them to BMP bitmaps20,PicConverter.zipRead over 50 and write 15 image file formats.21,labelblink.zipBlinks The Caption In A Label Box22,UnZipper.zipActiveX control designed to easily manipulate ZIP archives from within your application. 23,gurhancoolbuttonocx.zipGurhanCoolButton is a free ActiveX Control that Acts as a Flat Button. Background Pictures and Icons can be added with ease24,pktextline.zipTextbox with modern design25,DirScanner.zipDirScanner is a free ActiveX control designed to scan directory/drive and save results to a file26,activeEjecutor.zipThis control launches a program and waits until it has finished or27,REGASP.zipDLL which provides access to the Windows 2000 registry through Active Server Pages (ASP) code. 28,ColorProgressBar.zipReplaces the standard progress bar with one that is on the order of O(n^2) times faster, with color options, and directional options.29,MDITaskBarDemo.zipThis zip file contains all the code and procedures necessary to create and implement an MDI TaskBar control. 30,AnimatedAgent.zipTwo VBScripts which allow the users to INSTANTLY create MS Agent EMAIL and MS AGENT Web pages or add MS Agent to web pages31,label3d.zipThis ActiveX Control creates a 3D Label. 32,Shcmbbox1.zipShComboBox ActiveX Control v1.0 behaves exactly like the Combo box in Windows Explorer showing all the folders and even files in the Shell's namespace33,fldrvw21.zipFolderView ActiveX Control 2.1 allows you to add a Windows Explorer-like treeview in your application.34,controlcenterlefttrans.zipControl that centers text right, left or in the middle.35,BetaDBToolBar.zipDBToolBar (Database ToolBar) for Add, Edit, Delete, etc...36,CodeDll.zipMiniCalculator DLL that allows input keys/Calculation results directly into a TextBox, ComboBox, etc.37,hyperlink082800.zipThis Hyperlink ActiveX Control will allow you to insert an Hyperlink which will be very useful if you want to give a link to your website from your program. 38,DropdownCalculator.zipNice Drop-Down ActiveX Control Calculator. It is like a combo box, but it will drop down a calculator, which you can use for calculation39,ColorPicker1.zipIt is a color picker control, which is almost similar to those you find in MS Office 2000 applications.40,PowerPrint.zipEasiest way to print. This Will Print Left Align, Right Align, Center Align. OCX. Full demonstration easy to use.41,fb.zipFolder Browser lets you select the directories the easy and elegant way.42,TimeLed.zipThis simple ActiveX control shows a graphic clock with led simulation43,MouseHook.zipThis control provides a nice, elegant way of reacting to the movement of the mouse wheel and other mouse functionality44,rscomm.zipSerial Comm control that provides the ability to send and receive 5 bit baudot with its built in ASCII to baudo and baudo to ASCII converter. Also can tx and rx any baudrate 45 to 115k!45,Mouse.zipVery useful mouse events, such as MouseMove, MousePosition, ClickRightButton, ClickLeftButton and etc.46,cdwriter.zipThis is a relatively simple cd writer code, comes with a freeware ocx. 47,converter.zipThis example project shows you how to use my binary.ocx. 48,autoreg.zipAuto easy, fast super Register/Unregister ocx/dll files at the same time!49,EasterEgg.zipthis is an EasterEgg OCX that you can drop on to your about form. 50,imgedit.zipImgEdit is an image-processing tool. It allows you to adjust brightness, contrast and saturation. 51,xshow.zipA control to create screensavers and/or slideshows. Choose from more than 120 transition effects between bitmap images.52,mp3enc.zipMP3 encoder. Source code for OCX not included.53,opendialog.zipAn extended Dialog Box like VB dialog style, with New, open, Recent files and preview. 54,SJIni.zipShareware OCX for manipulating INI files. Fast, easy, effective way to manipulate INI files.55,SoundSource.zipBrainFusion Presents The Dancer.Ocx Which is capable of reading The Sound Peak Form Sound Card When Mp3 or Wav File Is Played 56,SysUSATimeZONE.zipGet's Time From Anywhere In USA. Just By Typing In The State Abbreviation. 57,adbevel.zipVisual Basic now has a bevel control like Delphi. 58,RebootPlus.zipHere Is Another OCX File That Logs Off, Shutdown, Restart, Displays Device Manage, And Display Properties.59,RetCal10.zipThis Activex control creates retail calendars on the fly. very useful if you are in the retail, accounting, merchandising industries. Very cool check it out60,SysErrorOCX.zipOCX file that handles Database Errors. Contents Of This File Include.SysError.OCX 61,Appearence.zipSystem OCX allows you to change certain system display settings. 62,textbox1.zipSyntax highlighting text editor ... not based on the RTF box... supports drawing of external graphics on the text area...useful for html editors etc63,Player.zipA multimedia ocx to replace mediaplayer ocx64,Audio.zipThis ActiveX Control will play all kinds of MPEG-Layer3(MP3) files with ease of use. 65,HLiteDemo.zipHlite.Ocx When Placed On A Form And Called From A Textbox When It Has Focus It Will Highlight The Text Very Usefull In Data Entry Application66,SysBacUpDemo.zipThis Is A Demo Application Using A Ocx File To Backup Files. 67,OCXButton1.zipAn ActiveX control (OCX) for creating Buttons with attributes unavailable in the intrinsic CommandButton control of VB68,transferTV.zipTransfers values from one treeview to another recursively.69,createctrl.zipA float button control70,SysPCase.zipThis Is An OCX File That Will Allow a user to start typing and when textbox loses focus the OCX will make all text that user typed in into Proper Text Format71,SysErrorLogWriter.zipHere is an OCX file that will log all errors when placed under an event On Error Goto72,Pbar.zipThis is an OCX that has the nice Progress Bar that has the Percent in the middle It's nice and easy to use73,metawizardv101.zipMeta Wizard a small Meta Tag creation tool that takes advantage of the system toolbar and ontop properties. With this tool you can easily create Meta Tags74,Counter.zipFormatted number, long number counter, Thousand seperator75,barcode128.zipDBToolBar (Database ToolBar), to Add, Edit, Delete, etc...76,SwitchOCX.zipActiveX control.77,djmeter.zipA control (with VB Source) that is an implementation of a progress bar78,BtnGraphic.zipAn OCX someone made that allows you to easily create command buttons on forms, that act like an IE coolbar 79,HSoft11.zipThis is an OCX someone wrote that acts and looks almost identical to the IE3 toolbar80,MsgScroll.zipThis is a control (VB5 with source) that scrolls text81,mtymse.zipThis is a control (VB5 with source) that controls every aspect of the mouse82,progbar.zipUses a picture box to emulate a progress bar83,axcool.zipA toolbar control someone wrote84,axgrid.zipA Grid control someone wrote85,axpanel.zipA Panel, 3D Fram, Progress meter control someone wrote.86,browsef.zipA text box type control, that allows you to select a folder.87,browsfil.zipA text box type control, that allows you to select a file..88,colbrwse.zipA colour select control.89,colorsel.zipA drop down colour select control.90,FileOps.zipA VB5/6 control that allows you to easily copy, rename, put in trash, move files on your computer91,formmenu.zipA VB5/6 control that allows you to add menus to any place on a form you like92,hlitactx2.zipA VB5/6 control that shows you how to do code to see if the mouse is over a control on the screen. This one will highlight itself when the mouse id over it93,progbar2.zipA VB5/6 control that is a progress bar. Very good, allows lots of 94,spinedit.zipA spin control95,tilepuz.zipA control that simulates the tiled puzzle game96,urllabel2.zipA label control, but when you click on it, it starts up the default browser to a specified URL97,crdsrc.zipA whole deck of cards in a control, usfull for using in your own program98,ode.zipA control that spins numbers around99,TaskBar_v0_5.zipA control that creates a task bar, onto which you can add other controls100,vbalilsc.zipA pure VB control, that is a replacment for the image list control101,DBControl.zipA control that has many usefull database functions within it, like add field, add column, compact, restore, create primary key etc..102,OvalButton.zipA control that is an oval command button103,VBocx002.zipDas Scroll Wheel kann als Scrollbar oder einfach nur zur graphischen Versch?nerung verwendet werden 104,VBocx003o.zipDiese Leuchtdiode l?sst sich rund oder viereckig anzeigen, und erzeugt dadurch einen grafisch aufmachenderen Eindruck!!!105,VBocx004o.zipBlendet einen Text von wei? nach schwarz ein!106,VBocx005o.zipWie hier sichtbar, zeigt diese OCX-Datei nur Ziffern an. Der Counter oben besteht aus 2, die Uhrzeit unten aus 6 LED-Ziffern. Bei der Uhr werden desweiteren 2 Labels als Trennung verwendet.107,VBocx006o.zipEine Progressbar, der einfach anzusteuernd die Farbe und den Text ausgibt.108,vbocx008o.zipEinfach zu bedienen, sieht gut aus, und lockert das Bild der Benutzeroberfl?che etwas auf! 109,VBocx007o.zipEin einfach zu bedienendes OCX, um dateien von Servern hoch oder runterzuladen!110,VBocx001.zipVerschlüsseler werden meist zum Schutz von Daten angewandt.111,SuperPack.zipSuper Fill is an OCX designed to extend VB Fill Style property. You can create user patterns andprocess the scan-lines coordinate returned from the control. This is a shareware control by Fabio Guerrazzi.112,supDraw.zipAnother control by Fabio Guerrazzi. Shareware.113,LEDBULB.zipThis OCX will represent strings in the form of led bulbs. By H.M.IMTHIAZ RAFIQ.114,delaunay.zipPerforms constrained triangulation, curve level and 3d mesh.115,Wolf.zipAnother ocx make example.116,OCXRegCode.zipThis will register your ocx.Comes with the complete source. Made by Neil Cuttriss.117,DDCalc.zipThis OCX Control is simple enough not to describe its use.118,Flash3D.zipThis shows you how to use the macromedia flash/shockwave ocx. Also demonstrates 3D animation in a vector based environment with Flash119,EnhPrint.zipOCX which creates a EMF-metafile dc class, which can be used by the vb programmer to create, print and/or preview a metafile120,hoverbutton.zipThis is an enhancement of the standard command button.121,scbox10.zipThis ActiveX control lets you add a shadow that falls behind a control.122,getfile.zipControl consisting of a text box and a button. User clicks the button, dialog shown 123,ftpActiveX.zipThis control shows how to use the Inet control for downloading files, uploading files, listing directories, renaming files, deleting files, creating directories and more!!124,TextBoxControl.zipThis text box control allows you to limit input based on datatype or numeric range. Validation occurs within the lost focus event.125,systray.zipAdd icons to the system tray with ease. The caption and icon can be set. 126,asRuler.zipThis is a basic Custom Contrl, which displayes a ruler.127,playing_card.zipSimple to use playing card activeX control with additional container with auto arrange function. 128,XPlayer.zipThis control functions much like windows media player and supports the following file formats: Dat, Avi, Mp3, Wav, Mpg & Wma files.129,DBImage.zipThis one is component that allows you to populate image data from a ADO field to the component just like you would populate a text field with text data from a text field.130,ellipctl.zipMake an elliptical ActiveX picture control
Contents xvii Web Forms 133 Intellisense 134 Customizing the IDE 135 Customizing the Code Editor 135 Customizing Shortcut Keys 135 Customizing the Toolbars 136 Exercise 3.4 Adding a New Toolbar to the Existing Set 136 Exercise 3.5 Adding Commands to Toolbars 137 Customizing Built-In Commands 137 Exercise 3.6 Creating an Alias 138 Customizing the Start Page 139 Accessibility Options 141 Summary 142 Solutions Fast Track 142 Frequently Asked Questions 143 Chapter 4 Common Language Runtime 145 Introduction 146 Component Architecture 148 Managed Code versus Unmanaged Code 150 Interoperability with Managed Code 152 System Namespace 153 File I/O 155 Drawing 156 Printing 157 Common Type System 158 Type Casting 160 Garbage Collection 163 Object Allocation/Deallocation 164 Close/Dispose 165 Summary 166 Solutions Fast Track 167 Frequently Asked Questions 168 Developing & Deploying… Embrace Your Parameters VB.NET is insistent upon enclosing parameters of function calls within parentheses regardless of whether we are returning a value or whether we are using the Call statement. It makes the code much more readable and is a new standard for VB programmers that is consistent with the standard that nearly all other languages adopted long ago. 153_VBnet_TOC 8/16/01 1:12 PM Page xvii xviii Contents Chapter 5 .NET Programming Fundamentals 171 Introduction 172 Variables 173 Constants 175 Structures 176 Program Flow Control 178 If…Then…Else 178 Select Case 182 While Loops 184 For Loops 186 Arrays 187 Declaring an Array 188 Multidimensional Arrays 189 Dynamic Arrays 191 Functions 192 Object Oriented Programming 196 Inheritance 196 Polymorphism 197 Encapsulation 197 Classes 198 Adding Properties 198 Adding Methods 200 System.Object 201 Constructors 201 Overloading 202 Overriding 203 Shared Members 205 String Handling 206 Error Handling 210 Summary 213 Solutions Fast Track 214 Frequently Asked Questions 217 NOTE When porting Visual Basic applications to Visual Basic .NET, be careful of the lower bounds of arrays. If you are using a for loop to iterate through the array, and it is hard-coded to initialize the counter at 1, the first element will be skipped. Remember that all arrays start with the index of 0. 153_VBnet_TOC 8/16/01 1:12 PM Page xviii Contents xix Chapter 6 Advanced Programming Concepts 219 Introduction 220 Using Modules 221 Utilizing Namespaces 222 Creating Namespaces 222 Understanding the Imports Keyword 226 Implementing Interfaces 229 Delegates and Events 232 Simple Delegates 235 Multicast Delegates 236 Event Programming 236 Handles Keyword 236 Language Interoperability 237 File Operations 239 Directory Listing 239 Data Files 241 Text Files 243 Appending to Files 246 Collections 246 The Drawing Namespace 248 Images 253 Printing 256 Understanding Free Threading 262 SyncLock 263 Summary 265 Solutions Fast Track 265 Frequently Asked Questions 267 Chapter 7 Creating Windows Forms 269 Introduction 270 Application Model 270 Properties 271 Manipulating Windows Forms 275 Properties of Windows Forms 275 Methods of Windows Forms 276 Creating Windows Forms 287 What Are Collections? Collectionsare groups of like objects. Collections are similar to arrays, but they don’t have to be redimensioned. You can use the Addmethod to add objects to a collection. Collections take a little more code to create than arrays do, and sometimes accessing a collection can be a bit slower than an array, but they offer significant advantages because a collection is a group of objects whereby an array is a data type. 153_VBnet_TOC 8/16/01 1:12 PM Page xix xx Contents Displaying Modal Forms 288 Displaying Modeless Forms 289 Displaying Top-Most Forms 289 Changing the Borders of a Form 289 Resizing Forms 291 Setting Location of Forms 292 Form Events 294 Creating Multiple Document Interface Applications 297 Creating an MDI Parent Form 297 Creating MDI Child Forms 298 Exercise 7.1 Creating an MDI Child Form 298 Determining the Active MDI Child Form 299 Arranging MDI Child Forms 299 Adding Controls to Forms 300 Anchoring Controls on Forms 301 Docking Controls on Forms 303 Layering Objects on Forms 304 Positioning Controls on Forms 304 Dialog Boxes 305 Displaying Message Boxes 306 Common Dialog Boxes 306 The OpenFileDialog Control 306 The SaveFileDialog Control 309 The FontDialog Control 311 The ColorDialog Control 313 The PrintDialog Control 315 The PrintPreviewDialog Control 316 The PageSetupDialog Control 321 Creating Dialog Boxes 322 Creating and Working with Menus 323 Adding Menus to a Form 323 Exercise 7.2 Adding a Menu to a Form at Design Time 323 Creating Dialog Boxes 1.Create a form. 2.Set the BorderStyle property of the form to FixedDialog. 3.Set the ControlBox, MinimizeBox, and MaximizeBox properties of the form to False. 4.Customize the appearance of the form appropriately. 5.Customize event handlers in the Code window appropriately. 153_VBnet_TOC 8/16/01 1:12 PM Page xx Contents xxi Dynamically Creating Menus 326 Exercise 7.3 Adding a Menu to a Form at Design Time 326 Adding Status Bars to Forms 328 Adding Toolbars to Forms 330 Data Binding 332 Simple Data Binding 332 Complex Data Binding 333 Data Sources for Data Binding 333 Using the Data Form Wizard 334 Using the Windows Forms Class Viewer 338 Using the Windows Forms ActiveX Control Importer 338 Summary 340 Solutions Fast Track 340 Frequently Asked Questions 344 Chapter 8 Windows Forms Components and Controls 347 Introduction 348 Built-In Controls 348 Label Control 351 LinkLabel Control 354 TextBox Control 357 Button Control 361 CheckBox Control 364 RadioButton Control 365 RichTextBox Control 367 TreeView Control 369 ListBox Control 371 CheckedListBox Control 374 ListView Control 376 ComboBox Control 381 DomainUpDown Control 384 NumericUpDown Control 386 PictureBox Control 388 TrackBar Control 389 Adding Items to a Combo Box at Design-Time 1.Select the ComboBox control on the form. 2.If necessary, use the Viewmenu to open the Properties window. 3.In the Properties window, click the Itemsproperty, then click the ellipsis. 4.In String Collection Editor, type the first item, then press Enter. 5.Type the next items, pressing Enterafter each item. 6.Click OK. 153_VBnet_TOC 8/16/01 1:13 PM Page xxi xxii Contents DateTimePicker Control 391 Panel Control 394 GroupBox Control 396 TabControl Control 397 Creating Custom Windows Components 399 Exercise 8.1:Creating a Custom Windows Component 399 Creating Custom Windows Controls 403 Exercise 8.2:Creating a Custom Windows Control 404 Summary 407 Solutions Fast Track 407 Frequently Asked Questions 408 Chapter 9 Using ADO.NET 409 Introduction 410 Overview of XML 411 XML Documents 411 XSL 411 XDR 412 XPath 412 Understanding ADO.NET Architecture 412 Differences between ADO and ADO.NET 414 XML Support 414 ADO.NET Configuration 415 Remoting in ADO.NET 415 Maintaining State 415 Using the XML Schema Definition Tool 416 Connected Layer 417 DataProviders 418 Connection Strings 418 Exercise 9.1 Creating a Connection String 419 Command Objects 421 DataReader 425 DataSet 426 XML Documents XML documents are the heart of the XML standard. An XML document has at least one element that is delimited with one start tag and one end tag. XML documents are similar to HTML, except that the tags are made up by the author. 153_VBnet_TOC 8/16/01 1:13 PM Page xxii Contents xxiii Disconnected Layer 427 Using DataSet 428 Relational Schema 428 Collection of Tables 430 Data States 431 Populating with the DataSet Command 432 Populating with XML 433 Populating Programmatically 434 Using the SQL Server Data Provider 435 TDS 436 Exercise 9.2 Using TypedDataSet 437 Remoting 439 Data Controls 440 DataGrid 440 Exercise 9.3 Using TypedDataSet and DataRelation 441 DataList 446 Repeater 450 Summary 454 Solutions Fast Track 454 Frequently Asked Questions 457 Chapter 10 Developing Web Applications 459 Introduction 460 Web Forms 461 A Simple Web Form 462 Exercise 10.1 Creating a Simple Web Form 462 How Web Forms Differ from Windows Forms 464 Why Web Forms Are Better Than Classic ASP 465 Adding Controls to Web Forms 467 Exercise 10.2 Adding Web Controls to a Web Form 468 Code Behind 473 NOTE Web form controls not only detect browsers such as Internet Explorer and Netscape, but they also detect devices such as Palm Pilots and cell phones and generate appropriate HTML accordingly. 153_VBnet_TOC 8/16/01 1:13 PM Page xxiii xxiv Contents How Web Form Controls Differ from Windows Form Controls 476 ASP.NET Server Controls 476 Intrinsic Controls 476 Bound Controls 478 Exercise 10.3 Using the DataGrid Control 478 Exercise 10.4 Customizing DataGrid Control 482 Custom Controls 487 Validation Controls 488 Exercise 10.5 Using the Validation Controls 489 Creating Custom Web Form Controls 492 Exercise 10.6 A Simple Custom Control 493 Exercise 10.7 Creating a Composite Custom Control 497 Web Services 504 How Web Services Work 505 Developing Web Services 505 Exercise 10.8 Developing Web Services 507 Web Service Utilities 509 Service Description Language 509 Discovery 510 Proxy Class 510 Consuming Web Services from Web Forms 511 Exercise 10.9 Consuming Web Services from Web Forms 511 Using Windows Forms in Distributed Applications 513 Exercise 10.10 Consuming Web Services from Windows Forms 514 Exercise 10.11 Developing a Sample Application 516 Summary 519 Solutions Fast Track 519 Frequently Asked Questions 521 153_VBnet_TOC 8/16/01 1:13 PM Page xxiv Contents xxv Chapter 11 Optimizing, Debugging, and Testing 523 Introduction 524 Debugging Concepts 524 Debug Menu 528 Watches 529 Breakpoints 531 Exceptions Window 532 Command Window 534 Conditional Compilation 536 Trace 538 Assertions 540 Code Optimization 541 Finalization 542 Transitions 542 Parameter Passing Methods 542 Strings 543 Garbage Collection 544 Compiler Options 544 Optimization Options 544 Output File Options 544 .NET Assembly Options 545 Preprocessor Options 546 Miscellaneous Options 546 Testing Phases and Strategies 546 Unit Testing 547 Integration Testing 547 Beta Testing 547 Regression Testing 548 Stress Testing 548 Monitoring Performance 548 Summary 550 Solutions Fast Track 551 Frequently Asked Questions 552 What Are Watches? Watchesprovide us with a mechanism where we can interact with the actual data that is stored in our programs at runtime. They allow us to see the values of variables and the values of properties on objects. In addition to being able to view these values, you can also assign new values. 153_VBnet_TOC 8/16/01 1:13 PM Page xxv xxvi Contents Chapter 12 Security 553 Introduction 554 Security Concepts 555 Permissions 555 Principal 556 Authentication 557 Authorization 557 Security Policy 558 Type Safety 558 Code Access Security 558 .NET Code Access Security Model 559 Stack Walking 559 Code Identity 561 Code Groups 562 Declarative and Imperative Security 564 Requesting Permissions 565 Demanding Permissions 570 Overriding Security Checks 572 Custom Permissions 576 Role-Based Security 578 Principals 578 WindowsPrincipal 579 GenericPrincipal 580 Manipulating Identity 581 Role-Based Security Checks 583 Security Policies 585 Creating a New Permission Set 588 Modifying the Code Group Structure 593 Remoting Security 600 Cryptography 600 Security Tools 603 Summary 606 Solutions Fast Track 607 Frequently Asked Questions 611 Within the .NET Framework, Three Namespaces Involve Cryptography 1.System.Security .CryptographyThe most important one; resembles the CryptoAPI functionalities. 2.System.Security .Cryptography.X509 certificatesRelates only to the X509 v3 certificate used with Authenticode. 3.System.Security .Cryptography.XmlFor exclusive use within the .NET Framework security system. 153_VBnet_TOC 8/16/01 1:13 PM Page xxvi Contents xxvii Chapter 13 Application Deployment 615 Introduction 616 Packaging Code 617 Configuring the .NET Framework 622 Creating Configuration Files 622 Machine/Administrator Configuration Files 623 Application Configuration Files 625 Security Configuration Files 626 Deploying the Application 629 Common Language Runtime 629 Windows Installer 630 CAB Files 631 Internet Explorer 5.5 632 Resource Files 633 Deploying Controls 637 Summary 639 Solutions Fast Track 640 Frequently Asked Questions 642 Chapter 14 Upgrading Visual Basic Applications to .NET 647 Introduction 648 Considerations Before Upgrading 648 Early Binding of Variables 649 Avoiding Null Propagation 650 Using ADO 651 Using Date Data Type 652 Using Constants 652 Considering Architecture Before Migration 653 Intranet/Internet Applications 653 Internet Information Server (IIS) Applications 654 DHTML Applications 655 ActiveX Documents 655 Client/Server and Multi-Tier Applications 655 Single-Tier Applications 656 Data Access Applications 656 WARNING You should under no circumstance edit the Security.config and Enterprise.config files directly. It is very easy to compromise the integrity of these files. Always use the Code Access Security Policy utility (caspol.exe) or the .NET Configuration tool; these will guard the integrity of the files and will also make a backup copy of the last saved version. 153_VBnet_TOC 8/16/01 1:13 PM Page xxvii xxviii Contents Data Types 657 Variants 657 Integers 658 Dates 658 Boolean 659 Arrays 659 Fixed-Length Strings 660 Windows API Data Types 661 Converting VB Forms to Windows Forms 662 Control Anchoring 664 Keyword Changes 665 Goto 666 GoSub 666 Option Base 666 AND/OR 666 Lset 666 VarPtr 667 StrPtr 667 Def 667 Programming Differences 668 Method Implementation 668 Optional Parameters 668 Static Modifier 669 Return Statement 669 Procedure Calls 670 External Procedure Declaration 671 Passing Parameters 672 ParamArray 672 Overloading 674 References to Unmanaged Libraries 677 Metadata 679 Runtime Callable Wrapper 681 COM Callable Wrapper 682 Properties 684 Working with Property Procedures 684 Control Property Name Changes 685 Default Property 687 Avoiding Null Propagation Nullpropagation means that if Null is used in an expression, the resulting expression is always Null. In previous versions of Visual Basic, the Null value disseminated throughout the expression. 153_VBnet_TOC 8/16/01 1:13 PM Page xxviii Contents xxix Null Usage 690 Understanding Error Handling 690 Exercise 14.1:Using Error Handling 692 Data Access Changes in Visual Basic .NET 693 Dataset and Recordset 694 Application Interoperability 694 Cursor Location 695 Disconnected Access 695 Data Navigation 695 Lock Implementation 696 Upgrading Interfaces 696 Upgrading Interfaces from Visual Basic 6.0 699 Using the Upgrade Tool 703 Exercise 14.2 Using the Upgrade Wizard 703 Summary 708 Solutions Fast Track 709 Frequently Asked Questions 712 Index 713 Contents xiii From the Series Editor xxxi Chapter 1 New Features in Visual Basic .NET 1 Introduction 2 Examining the New IDE 3 Cosmetic Improvements 3 Development Accelerators 5 .NET Framework 6 A Very Brief and Simplified History 6 .NET Architecture 7 ASP.NET 7 Framework Classes 8 .NET Servers 8 Common Language Runtime 8 History 8 Convergence 9 Object-Oriented Language 10 Object-Oriented Concepts 10 Advantages of Object-Oriented Design 11 History of Object Orientation and VB 13 Namespaces 13 Web Applications 13 Web Applications Overview 13 Web Forms 14 Web Services 15 HyperText Transport Protocol 16 Simple Object Access Protocol 17 .NET Architecture .NET Framework ASP.NET Updated ASP Engine Web Forms Engine Framework Classes System.Math, System.Io, System.Data, Etc. Common Language Runtime Memory Management Common Type System Garbage Collection .NET .NET Servers 153_VBnet_TOC 8/16/01 1:12 PM Page xiii xiv Contents Security 17 Type Safety 18 Casting 18 Data Conversion 19 Bitwise Operations 20 New Compiler 20 Compiling an Executable 20 Architecture 21 File Management in Previous Versions of VB 21 File Management 22 Changes from Visual Basic 6.0 23 Variants 23 Variable Lower Bounds 23 Fixed Length Strings 23 NULL Propagation 23 Other Items Removed 24 Function Values 24 Short Circuits 25 Properties and Variables 25 Variable Lengths 25 Get and Set 26 Date Type 26 Default Properties 27 Summary 28 Solutions Fast Track 28 Frequently Asked Questions 31 Chapter 2 The Microsoft .NET Framework 33 Introduction 34 What Is the .NET Framework? 34 Introduction to the Common Language Runtime 35 Using .NET-Compliant Programming Languages 37 Creating Assemblies 39 Using the Manifest 42 Compiling Assemblies 45 Assembly Cache 45 Locating an Assembly 45 153_VBnet_TOC 8/16/01 1:12 PM Page xiv Contents xv Private Assembly Files 51 Shared Assembly Files 51 Understanding Metadata 51 The Benefits of Metadata 52 Identifying an Assembly with Metadata 53 Types 53 Defining Members 54 Using Contracts 54 Assembly Dependencies 55 Unmanaged Assembly Code 55 Reflection 56 Attributes 57 Ending DLL Hell 58 Side-by-Side Deployment 58 Versioning Support 59 Using System Services 60 Exception Handling 60 StackTrace 61 InnerException 61 Message 61 HelpLink 62 Garbage Collection 62 Console I/O 62 Microsoft Intermediate Language 63 The Just-In-Time Compiler 63 Using the Namespace System to Organize Classes 64 The Common Type System 65 Type Safety 68 Relying on Automatic Resource Management 68 The Managed Heap 69 Garbage Collection and the Managed Heap 71 Assigning Generations 77 Utilizing Weak References 77 Security Services 79 Framework Security 80 Granting Permissions 81 NOTE Visualization is still key! Die-hard VB programmers may find themselves having a hard time visualizing all the new concepts in VB.NET (and we all know that proper logic visualization plays a big role in what we do). Something that may help is to think about VB.NET as a completely flexible language that can accommodate Web, console, and desktop use. 153_VBnet_TOC 8/16/01 1:12 PM Page xv xvi Contents Gaining Representation through a Principal 82 Security Policy 83 Summary 85 Solutions Fast Track 85 Frequently Asked Questions 88 Chapter 3 Installing and Configuring VB.NET 91 Introduction 92 Editions 92 Installing Visual Studio .NET 93 Exercise 3.1:Installing Visual Studio .NET 94 Installing on Windows 2000 99 The New IDE 100 Integrated Development Environment Automation Model 100 Add-Ins 104 Exercise 3.2 Creating an Add-In Using the Add-In Wizard 105 Wizards 109 Macros 109 Home Page 110 Project Options 112 Toolbox 116 Child Windows 120 Window Types 122 Arranging Windows 123 Task List 123 Exercise 3.3 Setting Up a Custom Token 124 TaskList Views 124 Locating Code 126 Annotating Code 126 Solution Explorer 127 Properties Window 129 Form Layout Toolbar 130 Hide/Show Code Elements 132 Installing Visual Studio .NET IPhase 1: Installing Windows components IPhase 2: Installing Visual Studio .NET IPhase 3: Checking for service releases 153_VBnet_TOC 8/16/01 1:12 PM Page xvi
1 , vb5dialog.zipThis demonstrates how to subclass the Common Dialog Dialogs and manipulate a specific Dialog.2 , cpnl.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).3 , vbo_progbar.zipImplement a common control progress bar with added features that are not accessable using COMCTL32.OCX! 4 , vbo_infolabel.zipThis control adds a great user-friendly interface with and icon and "Hover" ability. Based on a control seen in ICQ. 5 , vbo_checkcombo.zipAdd a checkbox to a combo box and use it to enabled/disable the combo! or whatever you would like to do with it! 6 , vbo_controlframe.zipCreate your own system button such as a Maximize, Minimize, Close, and many others with ease! 7 , vbo_ctextbox.zipThis class makes using the Textbox or Edit class API simple. Easily set properties and access many features not available directly from VB. 8 , taskbar.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).9 , NT_Service.zipThis is an OCX that allows you to create an NT service application...add the control to your project and register it as a service!!10 , Scroller.zipThis is a Control Container, it's like a frame control but it lets you scroll the content up and down...11 , TrayArea.zipThis control lets you add your icon to the System Tray Area and handle some events such as MouseMove, MouseDown, MouseUp and DblClick.12 , Resizer.zipThis is a very useful control: It's a container control, you can insert two controls inside and then you'll have a vertical (or horizontal) resizer bar (like the Windows File Explorer). A resizer can contain another resizer... an so on. (you can divide you form in as many sizable sections as you want...).13 , Label3D.zipTh
ADO组件的使用需要利用支持COM的高级语言,例如ASPVBScript或者Visual Basic,甚至Delphi,微软的竞争对手Borland的一个产品,现在也支持使用ADO来访问数据库。   在新的编程框架.NET Framework, 微软也提供了一个面向Internet的版本的ADO,称为ADO.NET。其对象模型和传统ADO差别很大。 ADO是一种面向对象的编程接口,微软介绍说,与其同IBM和Oracle提倡的那样,创建一个统一数据库,不如提供一个能够访问不同数据库的统一接口,这样会更加实用一些。为实现这一目标,微软在数据库和微软的OLE DB提供了一种“桥”程序,这种程序能够提供对数据库的连接。 开发人员在使用ADO时,其实就是在使用OLE DB,不过OLE DB更加接近底层。ADO的一项属性远程数据服务,支持“数据仓库”ActiveX 组件以及高效的客户端缓存。作为ActiveX的一部分,ADO也是COM组件的一部分。ADO是由早期的微软数据接口??远程数据对象RDO演化而来的。RDO同微软的ODBC一同连接关系数据库,不过不能连接非关系数据库。   ADO向我们提供了一个熟悉的,高层的对OLE DB的Automation封装接口。对那些熟悉RDO的程序员来说,你可以把OLE DB比作是ODBC驱动程序。如同RDO对象是ODBC驱动程序接口一样,ADO对象是OLE DB的接口;如同不同的数据库系统需要它们自己的ODBC驱动程序一样,不同的数据源要求它们自己的OLE DB提供者(OLE DB provider)。目前,虽然OLE DB提供者比较少,但微软正积极推广该技术,并打算用OLE DB取代ODBC。   ADO向VB程序员提供了很多好处。包括易于使用,熟悉的界面,高速度以及较低的内存占用(已实现ADO2.0的Msado15.dll需要占用342K内存,比RDO的Msrdo20.dll的368K略小,大约是DAO3.5的Dao350.dll所占内存的60%)。同传统的数据对象层次(DAO和RDO)不同,ADO可以独立创建。因此你可以只创建一个"Connection"对象,但是可以有多个,独立的"Recordset"对象来使用它。ADO针对客户/服务器以及WEB应用程序作了优化。
第一部分 了解COM 第1章 COM概述 何谓CoM COM术语 COM利与弊 COM的好处 COM的局限性 COM组件与接口 何谓接口 接口特征 接口类型 接口规则 接口设计 COM组件的实现规则 实现IUnknown规则 内存管理规则 引用计数规则 COM激活 COM类型 COM客户机 COM服务器 ActiveX控件 COM与面向对象技术 包装 抽象 多态 继承 COMTrader应用程序 小结 第2章 由VC++建立并使用COM服务器 IDL文件 建立第一个COM服务器 定义自定义接口 实现IUnknown和自定义接口 完成COM服务器 生成测试客户机 用ATL建立COM服务器 关于ATL 用ATL建立进程内COM服务器 用ATL建立进程外COM服务器 线程与COM服务器 Win32多线程应用 线程COM组件 自动化与IDispatch 用VC++实现IDispatch ATL与自动化 Automation数据类型 再谈类型库 C++自动化客户机 VB自动化客户机 小结 第3章 用VB建立并使用COM服务器 选择COM项目 设计接口 描述接口 浏览接口 生成对象 使用ClassBuilder 增加属性 增加方法 增加事件与枚举 使用ActiveXDataObject(ADO) 在服务器组件使用Recordset对象 在客户机组件使用ADOR 生成断开的Recodset 生成自己的RecodsctS 使用用户定义类型 错误处理 服务器客户机错误处理 使用VBErr.Raise机制 在VB使用线程模型 设置线程模型 了解再入性与公寓 小结 第二部分 COM与Internet 第4章 在VC++建立并使用ActiveX控件 ACtiveX控件概还 属性与方法 控件与容器通信 事件与连接点 建立第一个控件 生成控件 测试控件 增加方法 增加属性 增加事件 增加属性页 允许属性保持 使用控件 建立复合控件 增加复合控件 增加功能 增加事件 处理复合控件事件 处理错误 使用控件 小结 第5章 在VB建立并使用ActiveX控件 VB控件简介 约束与无约束控件 控件生成技术 属性类型 方法 属性配置 过程属性 环境属性配置 运行时只读属性 只在运行时有效的属性 扩展属性 容器属性 合成控件属性 可关联属性 持续与属性包 属性包 使用ActiveX控件界面向导 了解控件寿命 生成ActiveX控件 生成无约束控件 生成设计时数据约束控件 生成运行数据约束控件 小结 第6章 用VC++建立InternetCOM组件 IEActiveX控件 轻量级控件 安全控件 持续属性 文档对象模型编程 活动服务器组件 活动服务器页面 ASP页面的COM组件 小结 第7章 用VB建立InternetCOM组件 无窗口控件 ActiveX控件容器的线程模型 ActiveX控件的安全性 Web页面访问 VBDHTML项目 DHTML项目基础 DHTML应用程序样本 VBIIS应用程序 WebClass 一个IIS应用程序样本 设计控件 设计控件与HTML文件 样本设计控件 小结 第三部分 了解DCOM 第8章 DCOM概述 何谓DCOM 为什么使用DCOM DCOM操作 DCOM组件位置 进程内或进程外组件 代理 RPC(RemoteProcedureCall,远程过程调用) 调动 数据传递 DCOM配置实用程序 DCOM应用程序的安全机制 验证 授权 加密 整性检查 小结 第9章 用VC++建立DCOM服务器 标准与自定义调动 标准调动 自定又调动 网络通伯 远程激活 AppID注册表项 可配置AppID注册表项参数 IUknown优化 DCOM与NT服务 NT服务解剖 基于NT服务的COM服务器 小结 第10章 用VB建立DCOM服务器 应用程序对象模型 何谓对象模型 如何生成对象模型 DCOM设计准则与技术 再论调动 按数值与按引用 DCOM进程外服务器 建立DCOM组件 增加测试客户机 IIS应用程序 增加WebClasses 使用模板 增加自定义Webltems 远程错误处理 小结 第四部分 了解COM++ 第11章 COM++概述 COM与WindowsDNA 用户界面层技术 间层技术 数据库层技术 组件服务配置 事务处理 排队组件(QC) 实时结构的限制 事务性消息排队 排队组件结构 排队组件故障恢复 QC安全性 动态负荷平衡 对象地 小结 第12章 用VC++建立COM++组件 ADO编程 ADO与OLEDB VC++的ADO VC++的ADO扩展 建立COM++应用程序 温习IObjectContext接口 用ATL建立COM++组件 编制基于角色的安全性 处理COM+事务 控制事务结果 指定事务属性 确定事务情境 传递接口指针 共享状态 建立事务性COM+组件 小结 第13章 用VB建立COM+组件 了解事务 事务与多层应用程序 COM+与事务 事务属性:ACID COM+系统简介 COM+运行环境 COM+ComponentServices COM+接口 资源分配器 应用程序组件 探索COM+编程模型 COM+组件作为COMDLL 基本COM+编程规则 COM+API 用VB编程COM+ 对象描述表 COM+组件的生命周期 ObjectControl接口 MTS活动 COM+生成对象 安全引用 组件之间的参数传递 数据类型 使用分布式事务 分布式事务协调器(MSDTC) COM+事务的工作 事务与有状态对象 使用共享属性管理器(SPMSharedProperyManager) 小结 第14章 了解MSMQ 何谓MSMQ MSMQ的好处 MSMQ组件 队列 消息 MSMQ对象模型 MSMQ设置 MSMQ基础 消息发送 消息接收 MSMQ事件 MSMQ事务 小结 第五部分 高级COM与COM+ 第15章 VC++与VB的COM+服务 了解COM+激活 描述表包装器 激活顺序 使用即时(JIT)激活 使用对象构造 性公寓简介 了解同步域 表示事务状态 取得对象信息 使用对象地 对象池的好处 对象地要求 对象地配置 使用排队组件 QC限制 QC配置 QC调用 QC播放控件 使用负荷平衡 负荷平衡要求 负荷平衡配置 小结 第16章 COM与COM+安全性 何谓安全性 WindowsNT安全简介 NT验证 NT扮演 NT访问控制 COM安全结构 验证 访问控制 启动权限 标_ 扮演与掩盖 安全总括 COM+安全 COM+说明性安全 COM+角色 编程COM与COM+安全 整个进程安全 接口级安全 激活安全 服务器方安全 调用描述表安全信息 SecuntyProperty信息 安全性与数据库访问 小结 第17章 Windows2000的新COM特性 同步机制 COM同步API COM同步接口 异步COM 异步接口构造 异步接口调用 关于异步服务器与客户机 让服务器进行异步处理 调用序列化与自动完成 COM管道 COM管道接口 异步管道与提前读取 调用对象与调用取消 调用取消请求 调用取消处理 轻量级处理器 标准LWH 自定义LWH 小结 第六部分 调试与部署COM和COM+应用程序 第18章 调试与剖析COM和COM+应用程序 调试VB组件 调试MTS组件 调试COM+组件 使用条件编译 调试VC++组件 用VisualStUdioAnalyzer剖析 小结 第19章 部署COM与COM+应用程序 DCOM应用程序部署 配置DCOM服务器 配置DCOM客户机 在Internet上部署 Internet上部署与包装 签名CAB文件 许可ActiveX控件 自动化COM+配置 使用COMAdmin接口与集合 配置COM+应用程序 配置组件 配置角色 部署COM+应用程序 小结

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧