Diễn đàn sinh viên công nghệ thông tin, chia sẻ, giao lưu, học hỏi. Kết nối ... Những ngôn ngữ cơ bản mà bạn cần phải nắm nếu muốn thành 1 lập trình viên ...VuaTenMien.Com
Thứ Bảy, 27 tháng 4, 2013
ASP.NET: Thực thi truy vấn INSERT 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 InsertCommand As SqlCommand = New SqlCommand()
InsertCommand.Connection = conn
Dim sql As String = "INSERT INTO categories (categoryName) VALUES (@newCatName)"
InsertCommand.CommandText = sql
InsertCommand.Parameters.Add("@newCatName", SqlDbType.NVarChar, 250).Value = "Category Name"
Try
conn.Open()
InsertCommand.ExecuteNonQuery()
Catch ex As Exception
response.Write(ex.ToString())
Finally
conn.Close()
End Try
end sub
</script>
Đăng ký:
Đăng Nhận xét (Atom)
Bài đăng phổ biến
-
import java.io.*; public class Test_Ngto{ public static void main(String args[]){ InputStream is = System.in; ...
-
import java.io.*; public class ReadLine{ public static void main(String args[]){ InputStreamReader isr = new InputStreamReader...
-
1. Hãy xây dựng lớp Diem cùng với các đối tượng điểm trong mặt phẳng và các phương thức sau: - Phương thức khởi tạo - Phương...
-
<html> <head> <title>Giai phuong trinh bac 2</title> <script language="JavaScript"> function giai(fo...
-
import java.io.*; public class Test_Tng{ public static void main(String args[]){ InputStream is = System.in; ...
-
<%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespa...
-
<html> <head><script LANGUAGE="JavaScript"> function a_plus_b(form) { a=eval(form.a.value) ...
-
import java.io.*; public class Gptb2{ public static void main(String args[]){ InputStreamReader isr = new InputStream...
-
<html> <head> <title>giai phuong trinh bac 1</title> <script language="JavaScript"> function giai(fo...
-
<%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespa...
Không có nhận xét nào:
Đăng nhận xét