C#操作各种执行sql的方法含存储过程操作
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Data;
namespace MyDbTest
{
class Program
{
static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(
@"Data Source=localhost;Initial Catalog=CSGL;Persist Security Info=True;User ID=test;Password=test");
thisConnection.Open();
SqlCommand myCommand = new SqlCommand("P_Test", thisConnection);
myCommand.CommandType = CommandType.StoredProcedure;
//添加输入查询参数、赋予值
myCommand.Parameters.Add("@id", SqlDbType.Int);
myCommand.Parameters["@id"].Value = "120";
//添加输出参数
myCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
myCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
//得到存储过程输出参数
Console.WriteLine(" 存储过程的参数"+ myCommand.Parameters["@Rowcount"].Value.ToString());
thisConnection.Close();
Console.ReadLine();
//SqlCommand thisCommand = thisConnection.CreateCommand();
//thisCommand.CommandText = "select count(*) from stu";
////ExecuteScalar:执行只返回一个值的SQL命令。
//object countResult = thisCommand.ExecuteScalar();
//Console.WriteLine("Count of Customers={0}", countResult);
//thisConnection.Close();
//Console.ReadLine();
//SqlCommand thisCommand = thisConnection.CreateCommand();
//thisCommand.CommandText = "update stu set snm='haha' where id=120";
////Inset,Update,Delelte的数据修改操作也不返回任何数据,
////我们对这些命令感兴趣的是修改操作影响的行数,可以用ExecuteNonQuery()方法
//int rowsAffected = thisCommand.ExecuteNonQuery();
//Console.WriteLine("Rows Updated={0}", rowsAffected);
//thisConnection.
相关文档:
mysql可以运行在不同sql mode模式下面,sql mode模式定义了mysql应该支持的sql语法,数据校验等!
查看默认的sql mode模式:
select @@sql_mode;
我的数据库是:
STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
在此模式下面,如果插入的数据的长度大于定义的长度,那么就会报错!
......
我们可以使用XML作为数据传送、沟通的格式,Ajax客户端若要发送XML,基本上就是将XML作为字符串,在POST请求时发送,例如:
*HelloAjax.js
view plaincopy to clipboardprint?
var xmlHttp;
function createXMLHttpRequest() {
if (window.XMLHttpRequest) {   ......
第一节、SQL注入的一般步骤
首先,判断环境,寻找注入点,判断数据库类型,这在入门篇已经讲过了。
其次,根据注入参数类型,在脑海中重构SQL语句的原貌,按参数类型主要分为下面三种:
(A) ID=49 这类注入的参数是数字型,SQL语句原貌大致如下:
Select * from 表名 where
字段=49
注入的参数为ID=49 And [查询条件 ......
5.1 密码策略
由于sql server不能更改sa用户名称,也不能删除这个超级用户,所以,我们必须对这个帐号进行最强的保护,当然,包括使用一个非常强壮的密码,最好不要在数据库应用中使用sa帐号。新建立一个拥有与sa一样权限的超级用户来管理数据库。同时养成定期修改密码的好习惯。数据库管理员应该定期查看是否有不符合 ......
sql之left join、right join、inner join的区别
昨天面试8页笔试题目,基本上都是SQl 的,特别是这几个区别,记得不是很清晰,只记得left是以左表为主表,
right以右表为主表,导致做错了几个!今天搜了下!总算弄清楚了!以下是转帖!
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right j ......