Ö±½ÓÖ´ÐÐSQLÃüÁî
±êÇ©£ºÊý¾Ý·ÃÎÊ ADO.NET
Ö±½ÓÖ´ÐÐSQLÃüÁî Ö´ÐÐÃæÏò¼¯ºÏµÄ²Ù×÷£¨±ÈÈ磬¸üÐÂÂú×ãÌõ¼þµÄÒ»×éÊý¾Ý£©¿ÉÒÔÖ±½ÓÓÃSQLÃüÁҪ±ÈÓÃC#À©Õ¹µÄSQLÖ¸Áî¸üÓÐЧ¡£
ADO.NET ÌṩÁË SqlCommand ºÍ OleDbCommand¶ÔÏó£¬ËûÃÇÌṩÁË¿ÉÖ±½ÓÖ´ÐÐSQLÃüÁîµÄ·½·¨¡£
ÌáÈ¡µ¥Öµ£º
Àý£º
.....
SqlConnection thisConnection = new SqlConnection(@".........ConnectString.........");
thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "SELECT COUNT (*) from Customers ";
Object countResult = thisCommand.ExecuteScalar();
Console.WriteLine(countResult); //Êä³ö²éѯµ½µÄ¼Ç¼ÊýÄ¿
thisConnection.Close();
²»¼ìË÷Êý¾Ý£º
ÀàËÆSQL INSERT, UPDATE, DELETEµÄÐ޸IJÙ×÷²»ÐèÒª·µ»ØÊý¾Ý£¬Ö»ÐèÒªÖªµÀÓ°ÏìµÄÐÐÊý¡£
ÓÃExecuteNonQuery()·½·¨¡£
Àý£º
......
thisCommand.CommandText = "UPDATE Products SET UnitPrice=UnitPrice*1.05 WHERE SupplierId=12";
int rowAffe
Ïà¹ØÎĵµ£º
/*Á½ÖÖ·½·¨µÄÇ°Ì᣺1.±¾µØ·þÎñÆ÷µÄsqlserver agent·þÎñ±£Ö¤´¦ÓÚÆô¶¯×´Ì¬
2.Ô¶³Ì¼ÆËã»ú£¨¼ÆËã»ú¹ÜÀíÀ½¨Á¢Ò»¸öÆÕͨȨÏÞÓû§£¬²¢ÎªÆä¼ÓÉÏÃÜÂ루ÀýÈçÓû§ÃûΪkyle£¬ÃÜÂëΪ1234£©£¬Í¬Ê±ÔÚÄÇ̨»úÆ÷µÄ·ÇϵͳÅÌÀィһ¸öÃûΪbackupµÄ¹²ÏíÎļþ¼Ð£¬ÎªÁË°²È«ÁíÍâÉèÖÃÕ ......
create database example
use example
create table major
(
spno varchar(10) primary key not null,
spname varchar(20) not null
)
create table student
(
sno varchar(10) primary key not null,
sname varchar(10) not null,
ssex varchar(2) not null, ......
SQL½ØÈ¡×Ö·û´®
SUBSTRING
·µ»Ø×Ö·û¡¢binary¡¢text »ò image ±í´ïʽµÄÒ»²¿·Ö¡£ÓйؿÉÓë¸Ãº¯ÊýÒ»ÆðʹÓõÄÓÐЧMicrosoft SQL Server Êý¾ÝÀàÐ͵ĸü¶àÐÅÏ¢£¬Çë²Î¼ûÊý¾ÝÀàÐÍ¡£
Óï·¨
SUBSTRING ( expression & ......
±êÇ©£ºÊý¾Ý·ÃÎÊ ADO.NET
DataAdapter ¶ÔÏóÖеÄSQLÃüÁî ×¢£ºADO.NET¶ÔÏóÄ£ÐÍ ºÍ C# Òª±È SQL ¸üÊʺϴ¦Àí¸´ÔÓÔËËã ºÍ µ¼º½Âß¼£¨±ÈÈ磬²éÕÒÏà¹ØµÄÁíÒ»¸ö±íµÄÊý¾Ý£©
......