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

C#——·ÃÎÊSQL Server 2005¹«¹²Àà

ÏÂÃæÊÇÎÒ×ܽá³öÀ´µÄÒ»¸öÊý¾Ý¿â·ÃÎʹ«¹²À࣬»ùÓÚADO.NET£¬C#µÄ£¬ÆäÖУ¬ÒÔÖØÔصķ½Ê½ÊµÏÖʹÓôæÊô¹ý³ÌµÄ½Ó¿ÚºÍ²»Óô洢¹ý³ÌµÄ½Ó¿Ú£¬ÈçÓв»Í×Çë´ó¼ÒÖ¸Õý£¬Ð»Ð»~
×÷Õߣºshinehoo
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace shinehoo.db
{
/// <summary>
/// ¶ÔÊý¾Ý¿âµÄһЩ¹«¹²²Ù×÷
/// </summary>
public class DBOperate
{
/// <summary>
/// ½¨Á¢Êý¾Ý¿âÁ¬½Ó
/// </summary>
/// <returns>·µ»ØSqlConnection¶ÔÏó</returns>
public static SqlConnection getConnection()
{
SqlConnection myCon;
try
{
string strSqlCon = "Data Source = SHINEHOO-PC\\SQLEXPRESS; Initial Catalog = ShineHoo_DB; Integrated Security = True";
//SqlConnectionÀàÓÃÀ´Á¬½ÓÊý¾Ý¿â
myCon = new SqlConnection(strSqlCon);
}
catch (Exception e)
{
throw e;
}
return myCon;
}
/// <summary>
/// Ö´ÐÐSqlCommandÃüÁî
/// </summary>
/// <param name="strSqlCommand">SQLÓï¾ä</param>
public static void getCommand(string strSqlCommand)
{
SqlConnection sqlcon = getConnection();
try
{
//SqlConnectionÀàµÄOpen()·½·¨ÓÃÀ´´ò¿ªÊý¾Ý¿âÁ¬½Ó
sqlcon.Open();
//ÉùÃ÷½«¶ÔÊý¾Ý¿âÖ´ÐÐÒ»¸öSQLÓï¾ä»ò´æ´¢¹ý³Ì
SqlCommand sqlcom = new SqlCommand(strSqlCommand, sqlcon);
//Ö´ÐÐSqlCommandÃüÁî
sqlcom.ExecuteNonQuery();
}
catch (Exception e)
{
throw e;
}
finally
{
//¹Ø±ÕÊý¾Ý¿âÁ¬½Ó
sqlcon.Close();
//sqlcon.Dispose();
}
}


Ïà¹ØÎĵµ£º

C# ίÍеÄÃîÎÄ¡¾×ª¡¿

ίÍкÍʼþÔÚ .Net FrameworkÖеÄÓ¦Ó÷dz£¹ã·º£¬È»¶ø£¬½ÏºÃµØÀí½âίÍкÍʼþ¶ÔºÜ¶à½Ó´¥C#ʱ¼ä²»³¤µÄÈËÀ´Ëµ²¢²»ÈÝÒס£ËüÃǾÍÏñÊÇÒ»µÀ¼÷¶ù£¬¹ýÁËÕâ¸ö¼÷µÄÈË£¬¾õµÃÕæÊÇÌ«ÈÝÒ×ÁË£¬¶øûÓйýÈ¥µÄÈËÿ´Î¼ûµ½Î¯ÍкÍʼþ¾Í¾õµÃÐÄÀï±ð£¨bi裩µÃ»Å£¬»ìÉí²»×ÔÔÚ¡£±¾ÎÄÖУ¬ÎÒ½«Í¨¹ýÁ½¸ö·¶ÀýÓÉdzÈëÉîµØ½²ÊöʲôÊÇίÍС¢ÎªÊ²Ã´ÒªÊ¹Ó ......

C# ²Ù×÷XML£¬×Ô¼ºÓùýµÄ´úÂ룬¿ÉÄÜÖ»ÓÐÎÒÄÜ¿´¶®

public string WriteXML(string[] values, int flag)
{

//Èç¹ûflag==0ÔòΪµÚÒ»´ÎÔËÐÐÐèÒª³õʼ»¯XMLÎļþ
if (flag == 0)
{
//ÉúÔÚËæ»úÎļþÃû
string dateName = System.DateTime.Now.ToString("yyyyMMddHHmmss");
......

C# ³£¼û±ÊÊÔÌâ


1.    newÓм¸ÖÖÓ÷¨
    3ÖÖ ÊµÀý¶ÔÏó ·½·¨Òþ²Ø
2.ÈçºÎ°ÑÒ»¸öarray¸´ÖƵ½arrayListÀï
   foreach( object o in array )arrayList.Add(o);
3.datagrid.datasouse¿ÉÒÔÁ¬½ÓʲôÊý¾ÝÔ´
   Êý¾Ý¼¯DataSet
  
4.¸ÅÊö·´ÉäºÍÐòÁл¯
   ¶¯Ì¬»ñµÃ ......

c#ÊÂÎñ»Ø¹ö

c#ÊÂÎñ»Ø¹ö£¨×ª£©
×÷Õߣºxue5ya  À´Ô´£º²©¿ÍÔ°  ·¢²¼Ê±¼ä£º2009-03-20 16:08  ÔĶÁ£º263 ´Î  Ô­ÎÄÁ´½Ó   [ÊÕ²Ø]  
Code
public void UpdateContactTableByDataSet(DataSet ds,string strTblName) 

    ......

C#——µ÷Óô洢¹ý³Ì·½·¨

ÏÂÃæÊÇÎÒ×Ô¼º×ܽáµÄÒ»¸ö±È½Ï¼òµ¥µÄc#µ÷ÓÃSQL Server 2005´æ´¢¹ý³ÌµÄСÀý×Ó£¬Ö÷ÒªÊǽéÉÜÕû¸ö¹ý³Ì£¬ÓÐÎÊÌâµÄ»°Çë´óϺÃÇÖ¸µ¼£¬Ð»Ð»~
×÷Õߣºshinehoo
1£©´æ´¢¹ý³ÌÕâÑùдµÄ
ALTER PROCEDURE dbo.procShowLog
    (
    @StartTime datetime,
    @EndTime datetime,
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ