Có 140+ tài liệu thuộc chủ đề "kĩ thuật lập trình"
tailieu.vn Xem trực tuyến Tải xuống
You can create your own user-defined functions in SQL Server. You create a function using the CREATE. Inline table-valued functions Inline table-valued functions return an object of the table type. You can think of a table as a regular database table, except it is stored in memory. An inline table-valued function can return the results retrieved by only a single...
tailieu.vn Xem trực tuyến Tải xuống
So far, the examples you've seen have assumed that the updates pushed to the database by the Update() have succeeded. Note You'll find all the code examples shown in this section in the. HandlingUpdateFailures.cs file located in the ch11 directory. In the examples in this section, assume that the CommandText property of a SqlDataAdapter object's UpdateCommand is set as follows:....
tailieu.vn Xem trực tuyến Tải xuống
These DataTable objects will reference the Customers and Orders database tables. You'll then learn how to define a relationship between the two DataTable objects in the XML schema.. Enter the name of the project as DataRelation, as shown in Figure 12.2.. Figure 12.2: Creating the Windows application 2. Open Server Explorer and connect to the Northwind database using the connection...
tailieu.vn Xem trực tuyến Tải xuống
In this section, you'll see how to create a simple Windows application using VS .NET.. You'll also see how to compile and run the example application.. Start VS .NET by selecting Start ➣ Programs ➣ Microsoft Visual Studio .NET ➣ Microsoft Visual Studio .NET. Tip You can also create a new project by pressing Ctrl+Shift+N on your keyboard.. You'll see...
tailieu.vn Xem trực tuyến Tải xuống
this.myLabel = new System.Windows.Forms.Label();. this.myButton = new System.Windows.Forms.Button();. this.SuspendLayout();. this.myLabel.Location = new System.Drawing.Point(8, 8);. this.myLabel.Name = "myLabel";. this.myLabel.Size = new System.Drawing.Size(288, 184);. this.myLabel.TabIndex = 0;. this.myLabel.Text = "label1";. this.myButton.Location = new System.Drawing.Point(120, 200);. this.myButton.Name = "myButton";. this.myButton.Size = new System.Drawing.Size(72, 24);. this.myButton.TabIndex = 1;. this.myButton.Text = "Press Me!";. this.myButton.Click. new System.EventHandler(this.myButton_Click);. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);. this.ClientSize = new System.Drawing.Size(304,...
tailieu.vn Xem trực tuyến Tải xuống
In this section you'll plunge into ADO.NET programming and see a C# program that performs the following tasks:. Connects to the SQL Server Northwind database 2. Retrieves a row from the Customers table. Closes the database connection. You'll be introduced to many concepts in this section that are fully explored in later chapters. Don't be too concerned about all the...
tailieu.vn Xem trực tuyến Tải xuống
Step 3: Set the CommandText Property of the SqlCommand Object. Step 3 sets the CommandText property of mySqlCommand created in the previous step to a SELECT statement. This statement will retrieve the CustomerID, CompanyName, ContactName, and Address columns from the row in the Customers table whose CustomerID is ALFKI:. Step 4 opens the database connection using the Open() method of...
tailieu.vn Xem trực tuyến Tải xuống
You can use the ExecuteNonQuery() method of a Command object to execute any command that doesn't return a result set from the database. In this section, you'll learn how to use the ExecuteNonQuery() method to execute commands that modify. You can use the ExecuteNonQuery() method to execute SQL INSERT, UPDATE, and DELETE statements. You can also use the ExecuteNonQuery() method...
tailieu.vn Xem trực tuyến Tải xuống
Executing Multiple SQL Statements. That's a lot of network traffic! One way to potentially reduce network traffic is to execute multiple SQL statements at a time.. In this section, you'll see how to execute multiple SELECT statements and retrieve results, and you'll see how to execute multiple SELECT, INSERT, UPDATE, and DELETE statements that are interleaved.. Executing Multiple SELECT Statements....
tailieu.vn Xem trực tuyến Tải xuống
A Command object has three methods you can use to execute a SELECT statement or TableDirect command. Table 8.4 shows these methods, which you'll learn how to use in the following sections.. Table 8.4: METHODS THAT RETRIEVE INFORMATION FROM THE DATABASE. Applies only to the SqlCommand class.. Executing a SELECT Statement Using the ExecuteReader() Method Let's take a look at...
tailieu.vn Xem trực tuyến Tải xuống
Listing 8.3: SCHEMAONLYCOMMANDBEHAVIOR.CS. SchemaOnlyCommandBehavior.cs illustrates how to read a table schema. using System.Data;. using System.Data.SqlClient;. mySqlCommand.CommandText. "WHERE ProductID = 1";. display the rows and columns in the DataTable. ((System.Data.SqlDbType) myDataRow[myDataColumn]));. You should notice the different details for the ProductID, ProductName, and UnitPrice columns in the output that follows:. DataType = System.Int32 AllowDBNull = False ProviderType = 8 ProviderType = Int...
tailieu.vn Xem trực tuyến Tải xuống
Executing SQL Server Stored Procedures. You execute a stored procedure using the T-SQL EXECUTE statement. Although you can use this CommandType to indicate that a command is to execute a stored procedure, you're actually better off using the T-SQL EXECUTE command to execute a stored procedure. This is because you can read values that are returned from a stored procedure...
tailieu.vn Xem trực tuyến Tải xuống
except that it uses a RETURN statement instead of an OUTPUT parameter to return the ProductID for the new row. Listing 8.13: ADDPRODUCT2.SQL. AddProduct2.sql creates a procedure that adds a row to the Products table using values passed as parameters to the. The procedure returns the ProductID of the new row using a RETURN statement. so SCOPE_IDENTITY returns the ProductID...
tailieu.vn Xem trực tuyến Tải xuống
You'll find all the code examples shown in this section in the program UsingEvents.cs located in the ch11 directory. The events exposed by a SqlDataAdapter object are shown in Table 11.11.. Table 11.11: SqlDataAdapter EVENTS EVENT EVENT HANDLER DESCRIPTION. FillError FillErrorEventHandler Fires when an error occurs during a call to the Fill() method.. RowUpdating RowUpdatingEventHandler Fires before a row is...
tailieu.vn Xem trực tuyến Tải xuống
Figure 2.11 is a repeat of the diagram shown earlier that illustrates how these tables are related.. Figure 2.11: Relationships between the Customers, Orders, Order Details, and Products tables. For example, the Customers table contains 11 columns:. In the next few sections, you'll learn some database theory, and then you'll learn how each of the previous columns is defined in...
tailieu.vn Xem trực tuyến Tải xuống
Finding DataRowView Objects in a DataView. You can find the index of a DataRowView in a DataView using the Find() method of a DataView. You can also get an array of DataRowView objects using the FindRows() method of a DataView. You'll learn how to use the Find() and FindRows() methods in this section.. Finding the Index of a DataRowView Using...
tailieu.vn Xem trực tuyến Tải xuống
Each row in a DataTable is stored in a DataRow object, and in this section you'll learn how to find, filter, and sort the DataRow objects in a DataTable.. Retrieve the rows from the database into your DataTable.. Call the Find() method of your DataTable, passing the primary key column value of the DataRow you want.. productsDataTable.PrimaryKey = new DataColumn[]....
tailieu.vn Xem trực tuyến Tải xuống
In this section, you'll learn some of the essential programming constructs available in T- SQL. Specifically, you'll see how to use variables, comments, and conditional logic.. You'll also see how to use a number of statements that allow you to perform jumps and loops. Finally, you'll examine cursors, which allow you to process rows returned from the database one at...
tailieu.vn Xem trực tuyến Tải xuống
A database is an organized collection of information. A relational database is a. collection of related information that has been organized into structures known as tables.. Each table contains rows that are further organized into columns. You should already be familiar with information being represented in the form of a table with columns. For example, Table 2.1 shows the details...
tailieu.vn Xem trực tuyến Tải xuống
Introducing Stored Procedures. SQL Server allows you to store procedures in a database. Stored procedures differ from user-defined functions in that procedures can return a much wider array of data types.. You'll typically create a stored procedure when you need to perform a task that. intensively uses the database, or you want to centralize code in the database that any...