SQL 語法宣方式:
geometry::STGeomFromText('POINT('+ @X +' '+ @Y +')', 4326)
加入 Parameters 的方式
db.Parameters.Add("@X", SqlDbType.VarChar, X);
db.Parameters.Add("@Y", SqlDbType.VarChar, Y);
using Microsoft.Security.Application;
String APPLY_ID = Encoder.HtmlEncode((Request.QueryString["ID"]) ?? "");
String iHTML = @"<table class='TableStyle01_cont'>
<tr bgcolor='#E8E8FF' align='center'>
<th>項次</th>
<th>名稱</th>
<th>資料庫名稱</th>
</tr>
</table>";
Literal1.Text = Encoder.HtmlEncode(iHTML);
// Earlier = -1,
// Later = 1,
// TheSame = 0
DateTime EXPIRE_END_DATE = DateTime.Parse("2019-10-14 01:00:00");
if (EXPIRE_END_DATE.CompareTo(DateTime.Now) < 0 )
{
// "已過期!!"
}else if (EXPIRE_END_DATE.CompareTo(DateTime.Now) == 0 )
{
// "日期時間一樣"
}else if (EXPIRE_END_DATE.CompareTo(DateTime.Now) > 0 )
{
// "未過期!!"
}
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnStr"].ConnectionString);以下是解決方法:
![]() |
| 滑鼠右鍵,加入參考 |
![]() |
| 搜尋「system.configuration」 |
![]() |
| 出現在參考的清單裡 |
using Geolocation;
List points = new List();
Coordinate coordinate = new Coordinate();
coordinate.Latitude = 38.5;
coordinate.Longitude = -120.2;
points.Add(coordinate);
Response.Write("38.5 -120.2 ->" + Encode(points) + "
");
//解密
public static List Decodee(string polylineString)
{
List list = new List();
var polylineChars = polylineString.ToCharArray();
var index = 0;
var currentLat = 0;
var currentLng = 0;
while (index < polylineChars.Length)
{
var sum = 0;
var shifter = 0;
int nextFiveBits;
do
{
nextFiveBits = polylineChars[index++] - 63;
sum |= (nextFiveBits & 31) << shifter;
shifter += 5;
} while (nextFiveBits >= 32 && index < polylineChars.Length);
if (index >= polylineChars.Length)
break;
currentLat += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1);
sum = 0;
shifter = 0;
do
{
nextFiveBits = polylineChars[index++] - 63;
sum |= (nextFiveBits & 31) << shifter;
shifter += 5;
} while (nextFiveBits >= 32 && index < polylineChars.Length);
if (index >= polylineChars.Length && nextFiveBits >= 32)
break;
currentLng += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1);
Coordinate coordinate = new Coordinate();
coordinate.Latitude = Convert.ToDouble(currentLat) / 1E5;
coordinate.Longitude = Convert.ToDouble(currentLng) / 1E5;
list.Add(coordinate);
}
return list;
}
//加密
public static string Encode(List points)
{
var str = new StringBuilder();
var encodeDiff = (Action)(diff => {
int shifted = diff << 1;
if (diff < 0)
shifted = ~shifted;
int rem = shifted;
while (rem >= 0x20)
{
str.Append((char)((0x20 | (rem & 0x1f)) + 63));
rem >>= 5;
}
str.Append((char)(rem + 63));
});
int lastLat = 0;
int lastLng = 0;
foreach (var point in points)
{
int lat = (int)Math.Round(point.Latitude * 1E5);
int lng = (int)Math.Round(point.Longitude * 1E5);
encodeDiff(lat - lastLat);
encodeDiff(lng - lastLng);
lastLat = lat;
lastLng = lng;
}
return str.ToString();
}
比對後結果,感覺,Google Map Platform 網頁上第二和三筆是有問題的,不知道為什麼?
using MySql.Data.MySqlClient;
using System.Data;
DataTable dt = new DataTable();
MySqlConnection conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MISConnection"].ConnectionString);
conn.Open();
using (MySqlCommand cmd = new MySqlCommand())
{
string CmdText = @"select * from basic where PK=@PK";
cmd.Parameters.AddWithValue("@PK", PK);
cmd.Connection = conn;
cmd.CommandText = CmdText;
MySqlDataReader myData = cmd.ExecuteReader();
if (myData.HasRows)
{
dt.Load(myData);
}
}
conn.Close();
using System.Data;
using System.Data.SqlClient;
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DBConnStr"].ConnectionString);
cn.Open();
String PK = "1";
DataTable dt = new DataTable();
string _sql = @"select * from basic where PK=@PK";
using (SqlCommand cmd = new SqlCommand(_sql, cn))
{
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@PK", PK);
//cmd.ExecuteNonQuery();
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
dt.BeginLoadData();
da.Fill(dt);
}
}
cn.Close();
DataTable dt = new DataTable();
string filename = Server.MapPath(@"test.xls");
dt = ConvertExcelToDataTable(filename);
public static DataTable ConvertExcelToDataTable(string FileName)
{
System.Data.DataTable dtResult = null;
int totalSheet = 0; //No of sheets on excel file
using (OleDbConnection objConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1;';"))
{
objConn.Open();
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter oleda = new OleDbDataAdapter();
DataSet ds = new DataSet();
System.Data.DataTable dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string sheetName = string.Empty;
if (dt != null)
{
var tempDataTable = (from dataRow in dt.AsEnumerable()
where !dataRow["TABLE_NAME"].ToString().Contains("FilterDatabase")
select dataRow).CopyToDataTable();
dt = tempDataTable;
totalSheet = dt.Rows.Count;
sheetName = dt.Rows[0]["TABLE_NAME"].ToString();
}
cmd.Connection = objConn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM [" + sheetName + "]";
oleda = new OleDbDataAdapter(cmd);
oleda.Fill(ds, "excelData");
dtResult = ds.Tables["excelData"];
objConn.Close();
return dtResult; //Returning Dattable
}
}


![]() |
| 圖1 |
function createXMLHttpRequest() {
try { return new XMLHttpRequest(); } catch (e) { }
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { }
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { }
alert("XMLHttpRequest not supported");
return null;
}
var xmlHttpReq = createXMLHttpRequest();
xmlHttpReq.open("GET", "http://...網址?CIDS="+pics, false);
xmlHttpReq.send(null);
if (xmlHttpReq.responseText == "1")
{
}
==================== ashx ======================= using System;
using System.Web;
public class SaveReleasePic : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("1");
}
public bool IsReusable {
get {
return false;
}
}
}