且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Sql server Single Transction中的多记录删除

更新时间:2023-02-07 12:48:21

tblCustomers是您的自定义类型,而EmailID是压缩整数(ID)或字符串(电子邮件)...通过插入,tblCustomers甚至不包含emailID字段。



错误告诉您服务器需要SCALAR变量以便是你必须提供的。



示例:

tblCustomers is your custom type, while EmailID is pressumably integer (ID) or string (email)...by your insert, tblCustomers does not even contain emailID field.

The error tells you the server expects SCALAR variable so that is what you have to provide.

Example:
DELETE FROM Email
WHERE emailID IN (SELECT emailID FROM @tblCustomers)

-- this assumes tblCustomers really contains such field otherwise, you cannot do it.


使用System;

使用System.Collections.Generi c;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Windows.Forms;

使用System.IO;



命名空间Code.SearchFileContent

{

公共部分类Form1:表格

{

public Form1()

{

InitializeComponent();

}



private void button1_Click(object sender,EventArgs e)

{

SearchFileContent(@E:\Projects\Code.SearchFileContent\Code。 SearchFileContent);

}

public void SearchFileContent(string pDirectoryPath)

{

//修改此路径有必要的。





//拍摄文件系统的快照。

System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(pDirectoryPath);



//此方法假设应用程序具有发现权限

//适用于所有文件夹指定的路径。

IEnumerable< system.io.fileinfo> fileList = dir.GetFiles(*。*,System.IO.SearchOption.AllDirectories);



string searchTerm = @Visual Studio;



//搜索每个文件的内容。

//使用RegEx类创建的正则表达式

//可以用来代替Contains方法。

// queryMatchingFiles是一个IEnumerable< string>。



//执行查询。

string ssss = string.Empty;

Console.WriteLine(术语\{0} \见于:,searchTerm);

string fileText = string.Empty;

string line;

StringBuilder sb = new StringBuilder();



foreach(fileList中的FileInfo sss)

{

fileText + = GetFileText(sss.FullName);

label1.Text = sss.FullName;

using(System.IO.StreamReader file = new System.IO。 StreamReader(sss.FullName))

{

int lineno = 1;

while((line = file.ReadLine())!= null)

{

if(line.Contains(fileText + = GetFileText(sss.FullName);))

{

//这会将文本和换行符附加到StringBuilder缓冲区中

sb.AppendLine(sss.FullName ++ line.ToString()+ lineno + Environment .NewLine);

}

lineno ++;

}



}


}





int counter = 0;



label1.Text =;

textBox1.Text = sb.ToString();

//保留控制台窗口在调试模式下打开。



}



//读取文件内容。

静态字符串GetFileText(字符串名称)

{

string fileContents = String.Empty;



//如果文件已被删除,因为我们拍摄了快照,请忽略它并返回空字符串。

if(System.IO.File.Exists(name))

{

fileContents = System.IO.File.ReadAllText(name) ;



}

返回fileContents;

}

}

}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Code.SearchFileContent
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
SearchFileContent(@"E:\Projects\Code.SearchFileContent\Code.SearchFileContent");
}
public void SearchFileContent(string pDirectoryPath)
{
// Modify this path as necessary.


// Take a snapshot of the file system.
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(pDirectoryPath);

// This method assumes that the application has discovery permissions
// for all folders under the specified path.
IEnumerable<system.io.fileinfo> fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories);

string searchTerm = @"Visual Studio";

// Search the contents of each file.
// A regular expression created with the RegEx class
// could be used instead of the Contains method.
// queryMatchingFiles is an IEnumerable<string>.

// Execute the query.
string ssss = string.Empty;
Console.WriteLine("The term \"{0}\" was found in:", searchTerm);
string fileText = string.Empty;
string line;
StringBuilder sb = new StringBuilder();

foreach (FileInfo sss in fileList)
{
fileText += GetFileText(sss.FullName);
label1.Text = sss.FullName;
using (System.IO.StreamReader file = new System.IO.StreamReader(sss.FullName))
{
int lineno = 1;
while ((line = file.ReadLine()) != null)
{
if (line.Contains("fileText += GetFileText(sss.FullName);"))
{
// This append the text and a newline into the StringBuilder buffer
sb.AppendLine(sss.FullName + "" + line.ToString() + lineno + Environment.NewLine);
}
lineno++;
}

}

}


int counter = 0;

label1.Text = "";
textBox1.Text = sb.ToString();
// Keep the console window open in debug mode.

}

// Read the contents of the file.
static string GetFileText(string name)
{
string fileContents = String.Empty;

// If the file has been deleted since we took
// the snapshot, ignore it and return the empty string.
if (System.IO.File.Exists(name))
{
fileContents = System.IO.File.ReadAllText(name);

}
return fileContents;
}
}
}