C#²Ù×÷¸÷ÖÖÖ´ÐÐsqlµÄ·½·¨º¬´æ´¢¹ý³Ì²Ù×÷
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Data;
namespace MyDbTest
{
class Program
{
static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(
@"Data Source=localhost;Initial Catalog=CSGL;Persist Security Info=True;User ID=test;Password=test");
thisConnection.Open();
SqlCommand myCommand = new SqlCommand("P_Test", thisConnection);
myCommand.CommandType = CommandType.StoredProcedure;
//Ìí¼ÓÊäÈë²éѯ²ÎÊý¡¢¸³ÓèÖµ
myCommand.Parameters.Add("@id", SqlDbType.Int);
myCommand.Parameters["@id"].Value = "120";
//Ìí¼ÓÊä³ö²ÎÊý
myCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
myCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
//µÃµ½´æ´¢¹ý³ÌÊä³ö²ÎÊý
Console.WriteLine(" ´æ´¢¹ý³ÌµÄ²ÎÊý"+ myCommand.Parameters["@Rowcount"].Value.ToString());
thisConnection.Close();
Console.ReadLine();
//SqlCommand thisCommand = thisConnection.CreateCommand();
//thisCommand.CommandText = "select count(*) from stu";
////ExecuteScalar£ºÖ´ÐÐÖ»·µ»ØÒ»¸öÖµµÄSQLÃüÁî¡£
//object countResult = thisCommand.ExecuteScalar();
//Console.WriteLine("Count of Customers={0}", countResult);
//thisConnection.Close();
//Console.ReadLine();
//SqlCommand thisCommand = thisConnection.CreateCommand();
//thisCommand.CommandText = "update stu set snm='haha' where id=120";
////Inset,Update,DelelteµÄÊý¾ÝÐ޸IJÙ×÷Ò²²»·µ»ØÈκÎÊý¾Ý£¬
////ÎÒÃǶÔÕâЩÃüÁî¸ÐÐËȤµÄÊÇÐ޸IJÙ×÷Ó°ÏìµÄÐÐÊý£¬¿ÉÒÔÓÃExecuteNonQuery()·½·¨
//int rowsAffected = thisCommand.ExecuteNonQuery();
//Console.WriteLine("Rows Updated={0}", rowsAffected);
//thisConnection.
Ïà¹ØÎĵµ£º
master..xp_dirtree 'D:\',1,1 µÚÒ»¸ö1ÊÇÉî¶È£¬µÚ¶þ¸ö1ÊÇÎļþ
1. Ö´ÐÐ master..xp_dirtree 'c:\',1,1,ÕâÑù¿ÉÒÔ»ñÈ¡c:\ϵÄËùÓÐÎļþºÍÎļþ¼Ð,²»°üÀ¨×ÓÎļþ¼Ð¼°Îļþ
2. ÏÔʾÔÚtreeviewÖÐ,ÓñêÖ ......
¡¡¡¡¡¡ÓÃc#¸øPDA×öÁËÒ»¸öPC¶ËµÄͨѶ³ÌÐò£¬ÐèÒª±£´æÁ½¸ö²ÎÊý¡£ÓÃDelphiʱ£¬ÊDZ£´æÔÚiniÎļþÖУ¬c#¶ÁдXML±È½Ï·½±ã£¬¾ÍÓÃxmlÎļþÀ´±£´æÁË¡£
¡¡¡¡¡¡
¡¡
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// ÏÂÔØµ½PDAµÄTXTÎļþ·¾¶¡¡
/// </summary>
......
±ê׼˳ÐòµÄ SQL Óï¾äΪ:
Select ¿¼ÉúÐÕÃû, max(×ܳɼ¨) as max×ܳɼ¨
from tb_Grade
where ¿¼ÉúÐÕÃû is not null
group by ¿¼ÉúÐÕÃû
having max(×ܳɼ¨) > 600
order by max×ܳɼ¨
ÔÚÉÏÃæµÄʾÀýÖÐ SQL Óï¾äµÄÖ´ÐÐ˳ÐòÈçÏÂ:
(1). Ê×ÏÈÖ´ÐÐ from ×Ó¾ä, ´Ó tb_G ......
CREATE PROCEDURE [dbo].[PUB_CORP_SEARCH]
@oi_return INT OUTPUT , ......
sqlÖ®left join¡¢right join¡¢inner joinµÄÇø±ð
×òÌìÃæÊÔ8Ò³±ÊÊÔÌâÄ¿,»ù±¾É϶¼ÊÇSQl µÄ,ÌØ±ðÊÇÕ⼸¸öÇø±ð,¼ÇµÃ²»ÊǺÜÇåÎú,Ö»¼ÇµÃleftÊÇÒÔ×ó±íΪÖ÷±í,
rightÒÔÓÒ±íΪÖ÷±í,µ¼ÖÂ×ö´íÁ˼¸¸ö!½ñÌìËÑÁËÏÂ!×ÜËãŪÇå³þÁË!ÒÔÏÂÊÇתÌû!
left join(×óÁª½Ó) ·µ»Ø°üÀ¨×ó±íÖеÄËùÓмǼºÍÓÒ±íÖÐÁª½á×Ö¶ÎÏàµÈµÄ¼Ç¼
right j ......