一、MySql的基本语法
1、创建数据库
create database DB;
2、创建表
值得一提的是,mysql中bool类型用tinyint(1)来表示,1是真,0是假
create table Class
(
Id int primary key auto_increment,
Name varchar(20) not null,
);
create table UserInfo
(
Id int primary key auto_increment,
Name varchar(20) not null,
Sex tinyint(1) default'0',
ClassId int,
foreign key (ClassId) references Class(Id)
);
3、添加数据
insert into Class (Name) values ('1709A');
insert into UserInfo (Name,Sex,ClassId)values('张三',1,1)
4、删除数据
delete from UserInfo ;
delete from UserInfo where Id =1;
5、查询数据
select * from UserInfo
select a.`Name`,b.`Name` from UserInfo a inner join Class b on a.ClassId=b.Id
6、修改数据
update UserInfo set Name='李四' where Id =1;
update UserInfo set Name='李四',Sex=0 where Id =1;
ADO.NET( MySql连接 )
1、链接字符串
"Database=BookDB;Data Source=localhost;User Id=root;Password=******;charset='utf8';pooling=true"
2、和sqlserver的没啥区别,就是加了mysql几个字
WebService的Ajax跨域配置
1、web.config 节点下添加以下内容:
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
<add name="HttpSoap"/>
<add name="Documentation"/>
</protocols>
</webServices>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>
<add name="Access-Control-Allow-Headers" value="x-requested-with,content-type"/>
<add name="Access-Control-Allow-Origin" value="*"/>
</customHeaders>
</httpProtocol>
</system.webServer>
**
2.正确地编写webserivce的代码
若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 [System.Web.Script.Services.ScriptService]
3、 ajax访问WebService使用Post方式请求,并且规范数据内容为utf-8
$.ajax({
url: ''
, type: 'post
,contentType: "application/json;utf-8"
,dataType:'json'
, success: function (d) {
console.log(d)
}
})