ÓÃC#¶ÁSQL SERVERµ½¿ØÖÆÌ¨µÄ¼òµ¥Ê¾Àý
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserverÉí·ÝÑéÖ¤
//string sqlconn = "server=(local);database=keede1228;user id=sa;password=123;";
//windowsÉí·ÝÑéÖ¤
string sqlconn = "server=(local);database=keede1228;integrated security=SSPI;";
string select = "select * from dbo.lmShop_City";
SqlConnection conn = new SqlConnection(sqlconn);
Console.WriteLine("33");
conn.Open();
Console.WriteLine("11");
SqlCommand cmd = new SqlCommand(select, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("cityid:{0} city:{1} area:{2}", reader[0], reader[1], reader[2]);
}
conn.Close();
Console.WriteLine("22");
Console.ReadKey();
}
}
}
ÓÐÒ»µãÒÉÎÊ£º×îºóÊä³öµ½¿ØÖÆÌ¨µÄʱºò£¬Èç¹û²»¼Ó"cityid:{0} city:{1} area:{2}"¾Í»á±¨´í£¬²»ÖªµÀÊÇΪʲô£¬ºÃÏñÊÇÀàÐÍת»»µÄÊ£¬ÓÐÃ÷°×µÄ°ïÎÒ½â´ðһϣ¬Ð»Ð»¡£
Ïà¹ØÎĵµ£º
²éѯËÙ¶ÈÂýµÄÔÒòºÜ¶à£¬³£¼ûÈçϼ¸ÖÖ£º
¡¡¡¡1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
¡¡¡¡7¡¢ ......
2009-10-08 16:05
ʲôÊÇÊÓͼ
´ó¼Ò¶¼ÖªµÀ£¬ÎÒÃǹú¼ÒÏÖÔÚ“ÉñÆß”ÉÏÌìÁË¡£´ÓÃÀ¹úµÄÔÂÇòµÇÔ¿ªÊ¼£¬ÈËÀàÉÏÌì²»ÔÙÊÇÉñ»°¡£Ìý˵£¬ÔÚÃÀ¹ú£¬ÄãÖ»Òª³ö¼¸Ê®ÍòÃÀÔª£¬Äú¾Í¿ÉÒÔÉÏÒ»´ÎÔÂÇò½øÐÐÌ«¿ÕÂÃÐУ¬ËùÒÔ£¬ÎÒÃÇÏàÐÅ£ºÔÚ²»¾ÃµÄ½«À´£¬ÉÏÌìÂÃÐн«×ß½øÎÒÃǰÙÐÕµÄÉú»î£¬ÄÇÊÇÒ»¼þ¶àôÐÂÏÊÉñÆæµÄÊÂÇé° ......
Sql Server ÈÕÆÚ¸ñʽ»¯º¯Êý (ÀàËÆFormatº¯Êý),Ò»°ãÓÃÓÚ´æ´¢¹ý³ÌÖÐ
Sql Server ÖÐÒ»¸ö·Ç³£Ç¿´óµÄÈÕÆÚ¸ñʽ»¯º¯Êý
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(var ......
¶¯Ì¬Óï¾ä
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃexecÖ´ÐÐ
Select * from tableName
exec('select * from tableName')
exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
declare @fname varchar(20)
set @fname = 'FiledName'
Select @fnam ......
Ò»¡¢³£ÓÃÊý¾ÝÀàÐÍ£º
Number£ºÊý×ÖÀàÐÍ
Int£ºÕûÊýÐÍ
Pls_integer£ºÕûÊýÐÍ£¬²úÉúÒç³öµÄ´íÎó
Binary_integer£ºÕûÊýÐÍ
Char£º¶¨³¤×Ö·û£¬×255¸ö×Ö·û
Varchar2£º±ä³¤×Ö·û£¬×2000¸ö×Ö·û
Long£º±ä³¤×Ö·û£¬×2GB
Date£ºÈÕÆÚÐÍ
Boolean£º²¼¶ûÐÍ
¶þ¡¢¶¨Òå³£Á¿
¸ñʽ£º³£Á¿Ãû constant &nbs ......