下载  >  开发技术  >  C#  > C#数据库开发文档

C#数据库开发文档 评分

C#数据库开发文档用于开发技术提供的文档资料
C# Database basics Michael schmalz O REILLY Beijing· Cambridge· Farnham·Koln· Sebastopol· Tokyo 〔# Database basics by michael Schmalz Copyright@ 2012 Michael Schmalz. All rights reserved Printed in the United States of america Published by O Reilly Media, Inc, 1005 Gravenstein Highway North, Sebastopol, CA 95472 O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions arealsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformationcontactour corporate/institutionalsalesdepartment:(800)998-9938orcorporate@oreilly.com Editor: Simon St laurent Cover Designer: Karen Montgomery Production Editor: Holly bauer Interior Designer: David Futato Proofreader: O'Reilly Production Services lustrator robert romano Revision history for the first Edition 2012-01-25 First release Seehttp://oreilly.com/catalog/errata.cspisbn=9781449309985forreleasedetails Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, InC. C# Database Basics, the image of a capybara, and related trade dress are trademarks of O'Reilly media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as rademarks. Where those designations appear in this book, and O Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein ISBN:978-1-449-30998-5 1327510187 Table of contents Preface 1. First Steps: Form with a datagrid Installing Software Basic Syntax C# Operators Selection Statements Adding Filtering Some other Considerations 16 What's Next? 19 2. C# Data Access to SQL Server................... 21 What's Next 30 3. Building data Entry Forms 31 Binding a text Box to Data 32 Simple data entry Form 36 4. Creating Data Entry Forms with Built-In Controls .51 5. Data in a Web service Writing a Web service 64 What's Next 78 6. Editing Access Data on the Web. ......... 79 What's Next? 88 7. Additional C# and database Topics Referring to Connection Strings Building Strings with Database Data 91 Reporting 93 Exporting Tables to XML p-up 95 iv Table of Contents Preface Using databases in C# can be daunting for developers moving from VB6, VBA,or Access. From the differences in the. NET syntax to the curly braces and semicolons just looking at the code in C# for the first time can be intimidating. As you start to use C#, the small changes you need to make become easier and the code starts to flow nicely. However, you will likely find that many ways of working with data and databases that were easy in VB6 and vBa can be challenging when attempted for the first time in C# When you were programming in Classic VB, you could count on a good solid example of how to use a particular method, and it would be in context. For instance, if you were looking at a connection string example, it would likely include how to connect to the database, and it would probably also include a recordset or query. In C# and the other. NET languages, you will find fewer full examples and more examples that simply show the syntax. Or worse, they l show the other objects in the example, but won't explain how to create those objects or explain where the object needs to be declared (at the form level or at the procedure level What led to this book was a challenge that I faced while doing something that i thought should have been very simple. i wanted to create a form with a datagrid that would load a table or query at runtime with the ability to filter, sort and edit the records. I could do this task with Classic vb in a few minutes and in even less time with vBa inside of Access. With C#, there were pieces that were very simple, but only simple when building the connection to a single database and a single table that you define at design time. Getting code to change the datasource at runtime or connecting to a dif- ferent table when your database schema changes was significantly more challenging In addition, the help available online from within Visual Studio or even from an Internet search wasnt very complete. It isnt enough to know the method that you need to call you need to understand where the variables are declared, the changes that are needed to the properties on the datagrid the"using "references that are required, etc. Once you see it, the code is very clear, but it is less than straightforward when you are starting out Objectives This book teaches you some specific items to help you get started with C# and data- bases. You wont tackle a full project, but rather you will get a chance to use C# in a way that helps you learn by example. Many programmers learn best by simply doing using a concept in code that can eventually be applied to situations in the future. That is the essence of what you will accomplish by reading this book. no knowledge of c# or even vb is really required, but specific differences between Classic vB and C# will be highlighted. You dont even need to purchase any software; you can use the freely available Visual Studio Express and SQL Server Express if you don't have the full version of Visual Studio and/ or Microsoft office(for Access databases). also hould erally be able to cut and paste code that you generate while working through this book to use in your other projects When you finish this book, you should be able to do the following 1. Create a Windows Forms application with a datagrid 2. Connect to multiple data sources(Access and SQL Server 3. Add, Edit, and Update database data with a source set at runtime 4. Connect to a datasource at design time that cannot be changed 5. Understand roles of DataTable, Data View, Binding Source, Filters, and other ob Jects 6. Understand that where variables are declared impacts the code 7. Build a simple webservice that connects to a database As you follow the examples in this book, you will gain confidence in using C# and will be able to leverage this knowledge in other projects. Also, it is worth noting that both VB. Net and C# are powerful languages, and one isn't necessarily better than the other Typically, in the past, people have used VB and vB. Net for data-rich and line-of-busi ness applications and C# for the enterprise-level applications. But, this distinction is changing. It is true that if you are building a business application, many of the functions that you might want to use, such as net present value or other time value of money calculations, are built in to vB. Net and not to C#. which makes vB. Net the natural choice when you need that functionality However, given how data-intense the world is becoming, you simply must know how to access, add, update, and delete data in C# if you plan to program with it. You will be able to do that if you follow the examples in this book vi Preface Conventions Used in this book The following typographical conventions are used in this book italic Indicates new terms. URLs. email addresses filenames. and file extensions Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases data types, environment variables statements, and keywords Constant width bold Shows commands or other text that should be typed literally by the user Constant width italic Shows text that should be replaced with user-supplied values or by values deter- mined by context This icon signifies a tip, suggestion, or general note This icon indicates a warning or caution Using code examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you re reproducing a signiticant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product's documentation does require permission We appreciate, but do not require, attribution. an attribution usually includes the title, author, publisher, and IsBN. For example: C# database basics by michael Schmalz (O Reilly). Copyright 2012 Michael Schmalz, 978-1-449-30998-5 you feel your use of code examples falls outside fair use or the permission given above feelfreetocontactusatpermissions@oreilly.com Preface|ⅶi Safari books online Safari Books Online is an on-demand digital library that lets you easily Safari. search over 7, 500 technology and creative reference books and videos to find the answers you need quickly With a subscription, you can read any page and watch any video from our library online Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, down load chapters, bookmark key sections, create notes, print out pages, and benefit fr om tons of other time-saving teatures O'Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from O'Reilly and other pub lishers,signupforfreeathttp://my.safaribooksonline.com How to contact us Please address comments and questions concerning this book to the publisher O'Reilly media, Inc 1005 Gravenstein Highway North Sebastopol. ca 95472 800-998-9938(in the United States or Canada) 707-829-0515(international or local) 707-829-0104(fax We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://shop.oreillycom/product/0636920021469.do To comment or ask technical questions about this book, send email to bookquestions@oreilly.com For more information about our books. courses. conferences and news. see our website athttp://www.oreilly.com FindusonFacebook:http:/ifAcebook.com/oreilly FollowusonTwitterhttp://twitter.com/oreillymedia WatchusonYoutubehttp://www.youtubecom/oreillymedia ⅶ ii Preface

...展开详情
所需积分/C币:14 上传时间:2018-11-23 资源大小:3.03MB
举报 举报 收藏 收藏
分享 分享
C#帮助文档(中文版)

C#帮助文档,适合于从事C#开发的程序开发人员

立即下载
C#开发规范文档

C#开发规范文档,包括变量的定义,注释的编写规则,方法名的定义

立即下载
C#系统数据库开发经典案例源码

C#系统数据库开发经典案例,针对不同应用场景,灵活选用数据库。可以为使用者提供一定参考作用。

立即下载
数据库开发计划文档

数据库开发计划文档

立即下载
C#开发数据库系统

使用c#开发数据库应用系统,包涵了数据库的开发流程的讲义,适合喜欢做项目练习的人

立即下载
c#基础的 开发文档

主要适合c#基础开发人员。 主要适合c#基础开发人员。 主要适合c#基础开发人员。

立即下载
C#开发MC3200/MC32N0设备的开发文档及需要的所有开发包

开发MC3200手持扫描枪的一套窗体引用程序,顺带整理了开发过程中的步骤及所需要的第三方包。

立即下载