Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃ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}"¾Í»á±¨´í£¬²»ÖªµÀÊÇΪʲô£¬ºÃÏñÊÇÀàÐÍת»»µÄÊ£¬ÓÐÃ÷°×µÄ°ïÎÒ½â´ðһϣ¬Ð»Ð»¡£


Ïà¹ØÎĵµ£º

¾­µäSQLÓï¾ä´óÈ«(ÊʺÏSQL SERVER)


ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â ......

SQL ServerµÄ ÅÅÐò¹æÔò(collation)³åÍ»ºÍ½â¾ö·½°¸

ʲôÊÇÅÅÐò¹æÔò£¨collation£©
¹ØÓÚSQL ServerµÄÅÅÐò¹æÔò£¬¹À¼Æ´ó¼Ò¶¼²»Ä°Éú£¬ÔÚ´´½¨Êý¾Ý¿âʱÎÒÃǾ­³£ÒªÑ¡ÔñÒ»ÖÖÅÅÐò¹æÔò£¨conllation£©£¬Ò»°ãÎÒÃÇ»áÁôÒ⵽ÿһÖÖÓïÑÔµÄÅÅÐò¹æÔò¶¼ÓÐÐí¶àÖÖ£¬±ÈÈç±ê×¼´ó½¼òÌåÖÐÎÄChinese_PRCµÄÅÅÐò¹æÔò¾ÍÓÐÊýÊ®ÖÖÖ®¶à

ÕâЩÅÅÐò¹æÔòÓÐʲô×÷ÓÃÄØ£¿ÈÃÎÒÃÇÏÈÀ´¿´¿´MS¹Ù·½µÄ½âÊÍ£º
ÅÅÐò¹æÔ ......

¶¯Ì¬SQLÓï¾ä

¶¯Ì¬Óï¾ä
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 ......

SQL ServerÊÂÎñÈÕÖ¾½éÉÜ

SQL ServerÖеÄÊý¾Ý¿â¶¼ÊÇÓÉÒ»»ò¶à¸öÊý¾ÝÎļþÒÔ¼°Ò»»ò¶à¸öÊÂÎñÈÕÖ¾Îļþ×é³ÉµÄ¡£
¹ËÃû˼Ò⣬Êý¾ÝÎļþÖ÷Òª´æ´¢Êý¾Ý¿âµÄÊý¾Ý£¬°üÀ¨Êý¾Ý¿âÄÚÈݽṹ£¬Êý¾ÝÒ³£¬Ë÷ÒýÒ³µÈµÈ¡£ÄÇôÊÂÎñÈÕÖ¾µ½µ×ÊǸÉʲôµÄÄØ£¿ËüÖ÷ÒªÊÇÓÃÀ´±£´æÊý¾Ý¿âÐ޸ļǼµÄ£¬ÈçÏÂͼ£º
SQL ServerµÄ¹¤×÷Ô­ÀíΪʲôÕâÑùÄØ£¿ÎªÊ²Ã´²»°ÑÊý¾ÝÁ¢¿ÌдÈëÊý¾ÝÎļþÄØ£¿Ô­ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ