C# ÓÃSQLн¨Êý¾Ý¿â
1. ³ÌÐòÈçÏ£º
string str = "Create Database " + "DBname";
string con = "Data Source=10.0.0.249\\sql2005;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=sa";
SqlConnection myConn = new SqlConnection(con);
SqlCommand myCommand = new SqlCommand(str, myConn);
try
{
myConn.Open();
myCommand.ExecuteNonQuery();
Console.WriteLine("SQL Óï¾äÖ´ÐÐÍê³É¡£", "MyProgram");
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString(), "MyProgram");
}
finally
{
if (myConn.State == ConnectionState.Open)
{
myConn.Close();
Ïà¹ØÎĵµ£º
1£©²»Öª´ó¼ÒÊÇ·ñϲ»¶Ê¹ÓÑNOT IN’ÕâÑùµÄ²Ù×÷£¬Èç¹ûÊÇ£¬ÄǾ¡Á¿Ê¹ÓÃ(NOT) EXISTS Ìæ´ú
2£©ÔÚº£Á¿²éѯʱ¾¡Á¿ÉÙÓøñʽת»»¡£
3£©²éѯº£Á¿Êý¾ÝÊÇ£¬¿ÉÒÔʹÓÃoptimizer['ɔptimaizə] hints£¬ÀýÈç/*+ORDERED */
¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔ ......
C#Éú³Écom×é¼þ£¬¹©aspµ÷ÓÃ
Ò»¡¢vs2005—н¨ÏîÄ¿—C#Àà¿â
Àà¿âÔ´ÂëÈçÏÂ(°üº¬½Ó¿Ú£¬À࣬ʼþ½Ó¿Ú)£º
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
namespace entryclass
{
  ......
ÕâÁ½¸öÊý¾ÝÀàÐÍÊÇÎÒÃÇÔÚѧϰC#ÓïÑԵĹý³ÌÖÐÊý¾Ý±È½ÏÄѵÄÁ½¸öÊý¾ÝÀàÐÍ£¬²»¹ýËûÃǺÜÖØÒª£¬ËùÒÔÓбØÒªÄóöÀ´ËµËµËûÃǵÄʹÓ÷½·¨ºÍ²»Í¬Ö®´¦£¬Ï£Íû¶ÔÄãÓÐËù°ïÖú¡£
ÏÈ×ܵÄÀ´Ëµ£º
ͨ³£ÎÒÃÇÏò·½·¨Öд«µÝµÄÊÇÖµ.·½·¨»ñµÃµÄÊÇÕâЩֵµÄÒ»¸ö¿½±´,È»ºóʹÓÃÕâЩ¿½±´,µ±·½·¨ÔËÐÐÍê±Ïºó,ÕâЩ¿½±´½«±»¶ªÆú,¶øÔÀ´µÄÖµ²»½«Êܵ½Ó°Ïì.´ËÍâÎÒÃÇ ......
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
impo ......
1.×Ö·û´®º¯Êý
³¤¶ÈÓë·ÖÎöÓÃ
datalength(Char_expr) ·µ»Ø×Ö·û´®°üº¬×Ö·ûÊý,µ«²»°üº¬ºóÃæµÄ¿Õ¸ñ
substring(expression,start,length) ²»¶à˵ÁË,È¡×Ó´®
right(char_expr,int_expr) ·µ»Ø×Ö·û´®ÓÒ±ßint_expr¸ö×Ö·û
×Ö·û²Ù×÷Àà
upper(char_expr) תΪ´óÐ ......