Diễn đàn
Window Form programming
Lập trình với access khó phết
 | Thành viên | Nội dung | coder
 lap trinh khong bien gioi 137 bài
| bình thường thì thế này,
"Insert Into Contacts (FirstName, LastName) Values (@FirstName, @LastName)"
Nhưng với access phải chuyển thành
INSERT
[C#]
string ConnString = Utils.GetConnString();
string SqlString = "Insert Into Contacts (FirstName, LastName) Values (?,?)";
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("LastName", txtLastName.Text);
conn.Open();
cmd.ExecuteNonQuery();
}
}
[VB]
Dim ConnString As String = Utils.GetConnString()
Dim SqlString As String = "Insert Into Contacts (FirstName, LastName) Values (?,?)"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
UPDATE
[C#]
string ConnString = Utils.GetConnString();
string SqlString = "Update Contacts Set FirstName = ?, LastName = ?";
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("LastName", txtLastName.Text);
conn.Open();
cmd.ExecuteNonQuery();
}
}
[VB]
Dim ConnString As String = Utils.GetConnString()
Dim SqlString As String = "Update Contacts Set FirstName = ?, LastName = ?"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
DELETE
[C#]
string ConnString = Utils.GetConnString();
string SqlString = "Delete * From Contacts Where FirstName = ? And LastName = ?";
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("LastName", txtLastName.Text);
conn.Open();
cmd.ExecuteNonQuery();
}
}
[VB]
Dim ConnString As String = Utils.GetConnString()
Dim SqlString As String = "Delete * From Contacts Where FirstName = ? And LastName = ?"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
conn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
SELECT
[C#]
string ConnString = Utils.GetConnString();
string SqlString = "Select * From Contacts Where FirstName = ? And LastName = ?";
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
using (OleDbCommand cmd = new OleDbCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("LastName", txtLastName.Text);
conn.Open();
using (OleDbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
Response.Write(reader["FirstName"].ToString() + " " + reader["LastName"].ToString());
}
}
}
}
[VB]
Dim ConnString As String = Utils.GetConnString()
Dim SqlString As String = "Select * From Contacts Where FirstName = ? And LastName = ?"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text)
cmd.Parameters.AddWithValue("LastName", txtLastName.Text)
conn.Open()
Using reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
Response.Write(reader("FirstName").ToString() + " " + reader("LastName").ToString())
End While
End Using
End Using
End Using
|  |
Chủ đề gần đây :
Cùng loại :
|
Tên file
|
Người đăng
|
Ngày
|
Lượt
|
News Ticker Demo.rar
jQuery Carousellite cho cuộn các khối tin nhẹ nhàng mượt mà, sử dụng cho module Tin tức (CMS) hoặc giới thiệu sản phẩm
|
aspnet |
5/7/2011 8:59:52 AM |
475 |
cms_source_dll_sql_2010.rar
source C# + SQL Script + Dll module CMS trên DNN 5x, (bản chạy ổn định không lỗi)
|
aspnet |
9/5/2010 6:05:54 PM |
1863 |
killforever.rar
Script diệt virus forever.exe (lây nhiễm qua USB) mà không cần cài lại window
|
aspnet |
7/28/2010 6:51:30 AM |
264 |
CSharp Coding Standards.pdf
C# Coding standard, for all user, quy tắc viết mã lập trình c# dotnet.
|
aspnet |
6/1/2010 8:27:39 AM |
1228 |
weather_forex_gold.rar
module DNN : "vàng + thời tiết + tỷ giá ngoại tệ" của seekill
|
coder |
3/11/2010 3:50:09 AM |
1089 |
Training DotNetNuke.zip
Tài liệu hướng dẫn cài đặt DNN, tạo module DNN đơn giản, nâng cao
|
quanlv |
9/30/2009 9:11:36 AM |
2912 |
Viet va them 1 module don gian vao website.doc
Hướng dẫn viết module đơn giản trên DNN (word) có hình, gửi bởi vinahana
|
aspnet |
9/18/2009 6:15:24 PM |
1461 |
Moduel NEWs Demo.zip
Một số module bao gồm: News, WorkScheduler, QA, Comment, Menu, ...
|
quanlv |
8/22/2009 10:44:15 AM |
2543 |
MenuDNN5.rar
Menu DNN 51 Page.aspx
|
aspnet |
7/21/2009 12:22:38 PM |
1805 |
diendan.zip
Cài đặt diễn đàn (VSP) chỉ với 4 bước.
|
aspnet |
6/15/2009 2:18:13 AM |
1300 |
roll_updown.zip
Roll up, roll down news list using javascript, simple, easy to use.
|
radiogaga |
6/1/2009 11:29:51 AM |
423 |
rotator-1.0.0.rar
Auto Scroll News - tự động cuộn tin tức bằng JS
|
dotnetvn |
5/30/2009 3:21:22 PM |
623 |
captcha2.rar
CAPTCHA sinh ngẫu nhiên : size, font, position, color ... vẽ line gây nhiễu chống reCAPTCHA bot.
|
tieuphu |
5/30/2009 2:34:42 PM |
609 |
MenuDNN.zip
Menu Dọc cho DNN (Tác giả Võ Thế Quang)
|
biennv |
5/27/2009 8:07:47 AM |
1407 |
Gioi_thieu_san_pham_unisched4.zip
Giới thiệu phần mềm xếp thời khóa biểu đại học (University Scheduling 4.0) : áp dụng cho mô hình xếp thời khóa biểu niên chế, tại các trường đại học và cao đẳng tại việt nam
|
khanhjin |
5/12/2009 5:00:02 PM |
2852 |
HitCounterInDatabaseASPNET.zip
HitCounter
|
nguyentx |
4/20/2009 4:38:04 PM |
561 |
s3Slide.rar
Slide show chuyên nghiệp, giống tintuconline.com.vn
|
coder |
4/9/2009 9:34:41 AM |
2233 |
XMLPROG.zip
XML Programing C# dotnet
|
aspnet |
4/4/2009 10:02:43 AM |
603 |
menu_vnexpress.rar
Tạo menu giống vnexpress = xsl transform, C# dotnet, javascript(Toàn bộ mã nguồn).
|
coder |
3/30/2009 10:14:50 PM |
2367 |
DesktopModules.rar
CMS dotnetnuke + Image Library + Core CMS (DNN Data Provider) version 1.1
|
aspnet |
3/30/2009 5:23:14 PM |
1941 |
|