使用Access 2010中假设我有三个表:dogs,cats,和catChases。我的目标是创建一个查询,告诉我每只狗和每只猫,那只狗是否追过那只猫。
我想我必须使用dogsand的笛卡尔积cats,因为我想要所有可能组合的状态,然后 left join catChases,如下所示:
select
dog,cat,chase
from
dogs,cats
left join
catChases
on
dogs.dog=catChases.dog
Run Code Online (Sandbox Code Playgroud)
但这只是给了我一条错误消息:
Syntax error in JOIN operation.
那么我如何将另一个表连接到笛卡尔积?
我在弄清楚如何对功能进行单元测试时遇到了麻烦。它用于获取用户输入的密码样式,以便出现星号而不是用户键入的内容。因此,我试图捕获控制台I / O以将其与期望值进行比较。
这是功能:
public string getMaskedInput(string prompt)
{
string pwd = "";
ConsoleKeyInfo key;
do
{
key = Console.ReadKey(true);
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
{
pwd = pwd += key.KeyChar;
Console.Write("*");
}
else
{
if (key.Key == ConsoleKey.Backspace && pwd.Length > 0)
{
pwd = pwd.Substring(0, pwd.Length - 1);
Console.Write("\b \b");
}
}
}
while (key.Key != ConsoleKey.Enter);
return pwd;
}
Run Code Online (Sandbox Code Playgroud)
和测试:
public void getInputTest()
{
//arrange
var sr = new StringReader("a secret");
var sw = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下字符串定义的查询在ProjectWise的SQL Server数据库实例上运行ADODB查询:
select
dms_audt.o_acttime as actionTime,
dms_stat.o_statename as state,
dms_doc.o_filename as filename,
dms_doc.o_projectno as project
from dms_audt
inner join
dms_stat
on dms_audt.o_numparam2=dms_stat.o_stateno
inner join dms_doc on dms_audt.objguid=dms_doc.o_docguid
where substring(dms_doc.o_filename,1,4)="abcd")
and charindex(dms_doc.o_filename,"efgh")=0
Run Code Online (Sandbox Code Playgroud)
VBA给我一个运行时错误:
Incorrect syntax near ')'
Run Code Online (Sandbox Code Playgroud)
这让我觉得我无论是使用substring()或charindex()不正确.无论是用单引号还是双引号括起abcd和efgh字符串,我都收到了这个错误.知道我在这里做错了吗?
我的数据库中有两个表,Person和Action。 Person与有着一对多的关系Action。
我正在尝试构建一个Main具有Person表单和Action表单的表单,以便在Person单击的条目时,相应的条目会Action显示在Action子表单中。
但是,当我Main在设计模式下查看并在Action子窗体的属性中单击“链接主字段”时,出现以下错误消息:
Can't build a link between unbound forms.
Run Code Online (Sandbox Code Playgroud)
如何建立这种主子关系?
我正在尝试将字符串转换为"127.0"整数.
我试过这个功能:
int getInt(string numStr)
{
int result;
int.TryParse(numStr, out result);
return result;
}
Run Code Online (Sandbox Code Playgroud)
但当我把它称为int x = getInt("127.0");然后int.TryParse()设置result为0.
当我像这样重写函数时:
int getInt(string numStr)
{
result=Convert.ToInt32(numStr);
return result;
}
Run Code Online (Sandbox Code Playgroud)
同一个getInt()调用抛出此异常:
Input string was not in a correct format.
Run Code Online (Sandbox Code Playgroud) 我以通常的方式为一个类创建了Excel对象:
using Excel=Microsoft.Office.Interop.Excel;
但是,我将在这个项目中开发很多类,其中大部分都需要使用Excel对象,而且似乎我必须将它放在每个文件的标题中.有没有办法让我以某种方式using在项目级别输入此语句,这样我就不必在每个文件中添加它,并且如果由于某种原因我决定开始使用不同的Excel库,那么更容易更改?
c# ×3
ms-access ×2
namespaces ×1
sql ×1
sql-server ×1
t-sql ×1
unit-testing ×1
using ×1
vba ×1