惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
Jina AI
Jina AI
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
小众软件
小众软件
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
月光博客
月光博客
L
LangChain Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
C
Check Point Blog
U
Unit 42
人人都是产品经理
人人都是产品经理

博客园 - openkava

我的天涯助手V1 微软asp.net 2.0 rdlc报表发布到虚拟主机上 - openkava 恶意脚本代码分析 - openkava - 博客园 自用aspx小工具 cmd.aspx v1.2 数据库连接字符串 - openkava - 博客园 Jquery 使用笔记1 - openkava - 博客园 c# aspx 动态编译文件模板 - openkava c# 乱码解决方法 - openkava - 博客园 test zz巧用三个SQL视图查出所有的数据库字典 01 DiscuzNT1.0安装 编写的一个简单的ashx小程序 用bat文件搞定文件的备份 zz习惯的力量:35岁以前养成好习惯 竟然有免费送书的好事啊 Log4Net 使用心得 .net remoting 传递令牌 zz一篇很好的编码原理的文章 comesmith 4.1 试用笔记-
aspx最小代码连接数据库
openkava · 2008-06-26 · via 博客园 - openkava

<%@ Page language="c#"  codePage="65001"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Collections" %>
<%
//更新街道交叉口经纬度信息到数据库,如果没有,则插入,有则更新
// 用法: street1=华山路 & street2=衡山路 & lng=11111&lat=4444
System.Web.HttpContext context = this.Context;
System.Text.StringBuilder sb
=new System.Text.StringBuilder();
 context.Response.AddHeader(
"Prama","no-cache");
            context.Response.CacheControl
="private";
            context.Response.Expires
=0;
            
             context.Response.ContentType
="text/html";     
          
             
//获取参数
             string street1=Request["street1"];  
             
string street2=Request["street2"];
             
string lng        =Request["lng"];
             
string lat        =Request["lat"];
             
             
if(street1==null{street1="";}
             
if(street2==null{street2="";}
             
if(lng==null{lng="";}
             
if(lat==null{lat="";}
              
       
                     
//获取数据
             DataSet ds = new DataSet(); 
             
int r=0;
            
string  sql="";
            
string msgsuccess="操作成功<br/>";
            
string msgerror="不成功,没有记录<br/>";
            
string conn = "server=(local);database=callmeal;Uid=sa;Pwd=yyy;";
            SqlConnection con 
= new SqlConnection(conn);
            
             sql
=" select *  from street";  
             context.Response.Write(sql); 
             SqlCommand   _cmd
=new   SqlCommand(); 
             SqlDataAdapter da 
= new SqlDataAdapter(sql,conn);
             da.Fill(ds); 
             con.Open();                  
                _cmd.Connection 
=con;
                 
               //更新数据
                          sql
=" update street set lng=11 where streetid=1" 
                          _cmd.CommandText
=sql;
                        r
=_cmd.ExecuteNonQuery(); 
                   
if(r==-1
                        context.Response.Write(msgerror); 
                    
else
                        context.Response.Write(msgsuccess);  
                              
            con.Close();   
                       
         
          
//context.Response.Write(sql);
                      
//context.Response.Write(sb.ToString()); 
             context.Response.Flush();
            context.Response.Close();

 
 
%>