1. 看考云 > 知识库 >

commandtype,PowerShell 有哪些使用技巧

本文目录索引

1,PowerShell 有哪些使用技巧

你的问题确实问的太泛了,让人感觉不太好回答,可以给你看看Powershell中的快捷键用法

Important keys and their meaning in the PowerShell console


(Alt)+(F7) Deletes the current command history
(PgUp), (PgDn) Display the first (PgUp) or last (PgDn) command you used in current session
(Enter) Send the entered lines to PowerShell for execution
(End) Moves the editing cursor to the end of the command line
(Del) Deletes the character to the right of the insertion point
(Esc) Deletes current command line
(F2) Moves in current command line to the next character corresponding to specified character
(F4) Deletes all characters to the right of the insertion point up to specified character
(F7) Displays last entered commands in a dialog box
(F8) Displays commands from command history beginning with the character that you already entered in the command line
(F9) Opens a dialog box in which you can enter the number of a command from your command history to return the command. (F7) displays numbers of commands in command history
(Left arrow), (Right arrow) Move one character to the left or right respectively
(Arrow up), (Arrow down), (F5), (F8) Repeat the last previously entered command
(Home) Moves editing cursor to beginning of command line
(Backspace) Deletes character to the left of the insertion point
(Ctrl)+(C) Cancels command execution
(Ctrl)+(End) Deletes all characters from current position to end of command line
(Ctrl)+(Arrow left), (Ctrl)+(Arrow right) Move insertion point one word to the left or right respectively
(Ctrl)+(Home) Deletes all characters of current position up to beginning of command line
(Tab) Automatically completes current entry, if possible

PowerShell 有哪些使用技巧

2,powershell 什么 命令

关于PowerShell命令的一些基本知识
•PowerShell的命令叫做cmdlet
•具有一致的命名规范,都采用动词-名词形式,如New-Item
•动词部分一般为Add、New、Get、Remove、Set等
•命令的别名一般兼容Windows Command以及Linux Shell,如Get-ChildItem命令使用dir或ls均可
•PowerShell 命令产生的结果都是DLR对象
•PowerShell命令不区分大小写
以文件操作为例讲解PowerShell命令的基本用法
•新建目录 New-Item b2 -ItemType Directory
•新建文件 New-Item a.txt -ItemType File
•删除目录 Remove-Item b2
•递归列pre开头的文件或目录,只列出名称 Get-ChildItem -Recurse -Name -Filter "pre*“
•显示文本内容 Get-Content a.txt
•设置文本内容 Set-Content a.txt -Value "content1“
•追加内容 Add-Content a.txt -Value “content2“
•清除内容 Clear-Content a.txt

3,C#中CommandTYpe的定义在哪里

定义: SqlCommand cmd = new SqlCommand();//或者SqlCommand cmd = new SqlConnection().CreateCommand(); 注意参数
cmd.CommandType = CommandType.StoredProcedure; //存储过程
cmd.CommandType = CommandType.Text; //sql语句
cmd.CommandType = CommandType.TableDirect; System.Data.CommandType.TableDirect表示要执行的是表,此时,cmd.CommandText 的值应该是要查询表的的名称。查询结果返回的是整个表。

4,在ADO.NET中,为了执行一个存储过程,需要Command 对象的CommandType属性设置为(?)

这个commandtype的4个类型, 其实出现在了3个地方, 一个是recordset记录集的open方法时, 最后有个options,  一个是command对象在excute前的设置, 最后一个是通过ADO控件的属性页,在记录源里面有四个选项,也是需要在打开记录源之前选的。 也就是说,这厮就是为了控制recordset对象打开记录的。 一般text常用, 因为command对象指的就是比如sql server数据库里面中间那个能写查询命令的空白的地方。 也就是说执行查询后,以什么查询TYPE来打开通过查询得到的表表的~~! 一般就是 
set command.activeconnection=cc
command.commandtext="select * from table"
command.commandtype=adcmdtext
command.commandtimeout=30
set recordset=command.excute.
这样,就把查询语句的执行结果附给了 recordset。 说白了就是一种command属性。  

5,C#查询SQL数据库Command对象的方法问题

ExecuteScalar方法返回的类型是object类型,这个方法返回sql语句执行后的第一行第一列的值,由于不知到sql语句到底是什么样的结构(有可能是int,有可能是char等等),所以ExecuteScalar方法返回一个最基本的类型object,这个类型是所有类型的基类,换句话说:可以转换为任意类型。

ExecuteNonQuery方法是用来执行insert、delete、update语句的,由于这些语句执行后只有一个结果:“影响了**行”,所以ExecuteNonQuery方法返回的是影响的行数(int)。


虽然SQL中列的name本身就是字符串类型,但是你通过dataReader["name"]这种方式访问这个字段,必须强制类型转换,因为dataReader["name"]就像一个数组,数组中的每个元素的类型都应该一样,所以dataReader[]这个数组中的元素类型也被定义为object类型,以方便转换。

6,c#中怎么实现表的增删改查?

通过ADO.NET,可以写一个包含增删改的一个类函数(如下所示),要用的时候直接调用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace Load
{
class DBHelper
{
private static SqlCommand cmd = null;
private static SqlDataReader dr = null;


public int RowCount { get; private set; }

SqlConnection sqlCnn = new SqlConnection();
SqlCommand sqlCmd = new SqlCommand();
//数据库连接字符串
private static string connectionString = "Server = 127.0.0.1; Database = DB; Integrated Security =SSPI";
//数据库连接Connection对象
public static SqlConnection connection = new SqlConnection(connectionString);

public DBHelper()
{ }

#region 返回结果集

public static SqlDataReader GetResult(string sql)
{
try
{
cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = connection;
cmd.Connection.Open();
dr = cmd.ExecuteReader();
return dr;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
finally
{
}
}

#endregion

#region 对Select语句,返回int型结果集

public static int GetSqlResult(string sql)
{
try
{
cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = connection;
cmd.Connection.Open();

int a = (int)cmd.ExecuteScalar();
return a;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return -1;

}
finally
{
cmd.Connection.Close();
}
}

#endregion

#region 对Update,Insert和Delete语句,返回该命令所影响的行数

public static int GetDsqlResult(string sql)
{
try
{
cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = connection;
cmd.Connection.Open();

cmd.ExecuteNonQuery();
return 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return -1;
}
finally
{
cmd.Connection.Close();
}
}

#endregion

}
}

7,求泛型集合的增删改查的代码(c#)

public abstract class BaseDAL:IBaseDAL where T:class
{
net11Entities db = new net11Entities();
///
/// 查询
///
///
public List Select()
{
return db.Set().ToList();
}
///
/// 添加
///
///
///
public int Add(T m)
{
db.Set().Add(m);
return db.SaveChanges();
}
///
/// 删除
///
///
///
public int Del(Expression> where)
{
try
{
//DBContextFactory.GetDbContext();
var s= db.Set().Where(where).FirstOrDefault();
db.Set().Remove(s);
//db.Set().Remove(m);
return db.SaveChanges();
}
catch(Exception se)
{
return 0;
}
}
///
/// 修改
///
///
///
public int Upt(T m)
{
db.Set().Attach(m);
db.Entry(m).State = System.Data.EntityState.Modified;
return db.SaveChanges();
}
}
不知道是不是你想要的。。。。