SQL图片保存地址
iOS端代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *strURL = [[NSString alloc] initWithFormat:@"http://192.168.66.146/headURL/Default.aspx"];
NSURL *url = [NSURL URLWithString:[strURL URLEncodedString]];
__weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCompletionBlock:^{
NSData *data = [request responseData];
[singleManager sharedInstance].shareData =data;
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"%@", [error localizedDescription]);
}];
[request startAsynchronous];
textButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
textButton.frame=CGRectMake(20, 40, 280, 30);
[textButton setTitle:@"接收" forState:UIControlStateNormal];
[textButton setBackgroundColor:[UIColor greenColor]];
[textButton.layer setBorderWidth:1.0];
[textButton.layer setMasksToBounds:YES];
[textButton.layer setCornerRadius:10.0];
textButton.tag=1;
[textButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:textButton];
}
NET服务端代码
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace HeadURLDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//连接SQL数据库
System.Data.SqlClient.SqlConnection SqlCnn = new System.Data.SqlClient.SqlConnection("Data Source=JOHN;Initial Catalog=webservice;User ID=sa;Password=12345678;");
//打开数据库连接
SqlCnn.Open();
//加入SQL语句,实现数据库功能
System.Data.SqlClient.SqlDataAdapter SqlDa = new System.Data.SqlClient.SqlDataAdapter("select * from dbo.head", SqlCnn);
//创建缓存
DataSet DS = new DataSet();
//将SQL语句放入缓存
SqlDa.Fill(DS);
//获取第一张表
DataTable dt = DS.Tables[0];
string filename = (string)dt.Rows[0][0];
//Response.Redirect("~/" + "asihttp.png");
Response.Redirect("~/" + System.IO.Path.GetFileName(filename));
}
}
}