This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// 通过google将经纬度转换为地址描述 | |
/// </summary> | |
/// <param name="dlon"></param> | |
/// <param name="dlat"></param> | |
public static void geo2address(double dlon,double dlat) | |
{ | |
string sURL = "http://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}"; | |
string tagURL = string.Empty; | |
CookieCollection cookies = new CookieCollection(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string GetMd5Hash(MD5 md5Hash, string input) | |
{ | |
// Convert the input string to a byte array and compute the hash. | |
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); | |
// Create a new Stringbuilder to collect the bytes | |
// and create a string. | |
StringBuilder sBuilder = new StringBuilder(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION dbo.describe (@TABLENAME varchar(50)) | |
returns table | |
as | |
RETURN | |
( | |
SELECT TOP 1000 column_name AS [ColumnName], | |
IS_NULLABLE AS [IsNullable], | |
DATA_TYPE + '(' + CASE | |
WHEN DATA_TYPE = 'varchar' or DATA_TYPE = 'char' THEN | |
CASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
用直接拷贝的方法备份恢复 | |
根据本章前两节的介绍,由于MySQL的数据库和表是直接通过目录和表文件实现的,因此直接复制文件来备份数据库数据,对MySQL来说特别方便。而且自MySQL 3.23起MyISAM表成为缺省的表的类型,这种表可以为在不同的硬件体系中共享数据提供了保证。 | |
当使用直接拷贝的方法备份时,尤其要注意表没有被使用,你应该首先对表进行读锁定。 | |
在MySQL中备份一个表,需要三个文件: | |
对于MyISAM表: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> create table a like users; //复制表结构 | |
mysql> create table b select * from users limit 0; //复制表结构 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin tran | |
if exists (select * from std_UserObj with (updlock,serializable) where UserID = 1102 and ObjectID = 10078) | |
begin | |
update std_UserObj | |
set RelationShip = '妈妈' | |
where UserID = 1102 and ObjectID = 10078 | |
end | |
else | |
begin | |
insert std_UserObj (UserID,ObjectID,RelationShip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Source:http://www.codeproject.com/Tips/784090/Conversion-Between-DataTable-and-List-in-Csharp */ | |
/*Converts DataTable To List*/ | |
public static List<TSource> ToList<TSource>(this DataTable dataTable) where TSource : new() | |
{ | |
var dataList = new List<TSource>(); | |
const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic; | |
var objFieldNames = (from PropertyInfo aProp in typeof(TSource).GetProperties(flags) | |
select new { Name = aProp.Name, | |
Type = Nullable.GetUnderlyingType(aProp.PropertyType) ?? aProp.PropertyType }).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[UspOutputData] | |
@tablename sysname | |
AS | |
declare @column varchar(1000) | |
declare @columndata varchar(1000) | |
declare @sql varchar(4000) | |
declare @xtype tinyint | |
declare @name sysname | |
declare @objectId int | |
declare @objectname sysname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using System.Xml; | |
using System.Xml.Serialization; | |
// 此处代码来源于博客【在.net中读写config文件的各种方法】的示例代码 | |
// http://www.cnblogs.com/fish-li/archive/2011/12/18/2292037.html |