µ÷ÓÃSQL´æ´¢¹ý³Ì
±êÇ©£ºÊý¾Ý·ÃÎÊ ADO.NET
µ÷ÓÃSQL´æ´¢¹ý³Ì ´æ´¢¹ý³ÌÔÚÒ»¸öµ¥ÔªÖзâ×°Á˸´ÔÓµÄSQL²éѯºÍÊý¾Ý¹ý³Ì£¬¿ÉÒÔÓɶà¸ö³ÌÐò»òÓû§Ö®¼äµ÷Óá£
Àý£º
......
SqlConnection thisConnection = new SqlConnection(@"...........ConnectionString..............");
thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandType = CommandType.StoredProcedure; //½«SqlCommand¶ÔÏóµÄÃüÁîÊôÐÔÉèΪ ´æ´¢¹ý³ÌÀàÐÍ¡£
//CommandType.StoreProcedureÊÇADO.NETµÄÒ»¸öö¾Ù
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÔÚSQLÓï¾äÖУ¬³£³£Óûá¶Ôʱ¼ä£¨»òÈÕÆÚ£©½øÐÐһЩ´¦Àí£¬ÏÂÃæÊDZȽÏͨÓõÄһЩÓï¾ä£º
ÑÓ³Ù£º
sysdate+(5/24/60/60) ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ãë
sysdate+5/24/60 ÔÚϵͳʱ¼ä»ù´ ......
/*Á½ÖÖ·½·¨µÄÇ°Ì᣺1.±¾µØ·þÎñÆ÷µÄsqlserver agent·þÎñ±£Ö¤´¦ÓÚÆô¶¯×´Ì¬
2.Ô¶³Ì¼ÆËã»ú£¨¼ÆËã»ú¹ÜÀíÀ½¨Á¢Ò»¸öÆÕͨȨÏÞÓû§£¬²¢ÎªÆä¼ÓÉÏÃÜÂ루ÀýÈçÓû§ÃûΪkyle£¬ÃÜÂëΪ1234£©£¬Í¬Ê±ÔÚÄÇ̨»úÆ÷µÄ·ÇϵͳÅÌÀィһ¸öÃûΪbackupµÄ¹²ÏíÎļþ¼Ð£¬ÎªÁË°²È«ÁíÍâÉèÖÃÕ ......
//±¾³ÌÐòÁ¬½ÓµÄÊÇsql server 2005£¬ÓëÁ¬½Ósql server 2000Óе㲻ͬ£ºdriverNameºÍURL¶¼²»Í¬
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class create{
public void getConnection() th ......