Recent Posts

ASP.NET: Thực thi truy vấn DELETE sử dụng đối tượng SQLCommand

-

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>

<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)

Dim conn As New SQLConnection("server=LOCALHOST;User id='sa';password='123';database=Northwind")
Dim DeleteCommand As SqlCommand = New SqlCommand()
DeleteCommand.Connection = conn
Dim sql As String = "Delete from categories  WHERE CategoryID = @CatID"

DeleteCommand.CommandText = sql

DeleteCommand.Parameters.Add("@CatID", SqlDbType.Int).Value = 14
Try
conn.Open()
DeleteCommand.ExecuteNonQuery()
Catch ex As Exception
response.Write(ex.ToString())
Finally
conn.Close()
End Try

End sub

Related Post:

  • Code C#: Nhập vào số nguyên N có 3 chữ số. Tính tổng 3 chữ số đó//Viết chương trình Console Application, nhập vào số nguyên n có 3 chữ số. Hãy tính tổng 3 chữ số đó.namespaceBaiThucHanh1{    class Program{        static void Main(){            int n;            Console.Writ… Read More
  • Code C#: Nhập vào 2 số a, b. Tìm ước chung lớn nhất (UCLN) của a và b//Viết chương trình Console Application, nhập vào 2 số a và b. Tìm ước chung lớn nhất (UCLN) của 2 số a, b.class Program{        static void Main(){            inta, b;            do{       … Read More
  • Code C#: Ví dụ cấu trúc IF...ELSE//Viết chương trình cho phép nhập 3 số nguyên từ bàn phím. In ra số lớn nhất.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Max_3_so{class Program{static void Main(string[] args){int a, b, c;Console.Write("Nhap gia tri a:");a = int.Parse(Console.ReadLine());Console.Write("Nhap gia tri b:");b = int.Parse(Console.ReadLine());… Read More
  • Code C#: Ví dụ vòng lặp FOR//Ví dụ 1: Viết chương trình C# sử dụng cấu trúc FOR in ra màn hình kết quả như sau:****************************using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace FOR_LOOP_1{class Program{static void Main(string[] args){     int i,j;     for(i=0;i<=6;i++){           … Read More
  • HTML: Một số thẻ HTML cơ bản1. Thẻ <FONT>:- Dùng định dạng font chữ- Định dạng Font chữ cho cả tài liệu thì đặt tag <Font> trong phần <Body>- Định dạng từng phần hoặc từng từ thì đặt tại vị trí muốn định dạngCú pháp:<FONT Face=”fontName1, fontName2, fontName3” size=”value” Color=”rrggbb”>                      &nb… Read More
  • Code C#: Nhập 2 số từ bàn phím. Hoán vị 2 số đó//Viết chương trình Console Application, nhập vào 2 số a và b từ bàn phím. Hãy hoán vị 2 số đó. Ví dụ: a=5, b=7  => a=7, b=5namespaceLapTrinhCoBan{    class Program{        static void Main(){            inta,b,temp;      … Read More




Klik untuk melihat kode: :) =( :s :D :-D ^:D ^o^ 7:( :Q :p T_T @@, :-a :W *fck* x@