我有一个这样的程序:
mysql> call Ticket_FiscalTotals(100307);
+---------+--------+----------+------------+------------+
| Service | Items | SalesTax | eTaxAmount | GrandTotal |
+---------+--------+----------+------------+------------+
| 75.00 | 325.00 | 25.19 | 8.00 | 433.19 |
+---------+--------+----------+------------+------------+
1 row in set (0.08 sec)
Run Code Online (Sandbox Code Playgroud)
我想在select中调用这个过程,如下所示:
SELECT Ticket.TicketID as `Ticket`,
Ticket.DtCheckOut as `Checkout Date / Time`,
CONCAT(Customer.FirstName, ' ', Customer.LastName) as `Full Name`,
Customer.PrimaryPhone as `Phone`,
(CALL Ticket_FiscalTotals(Ticket.TicketID)).Service as `Service`
FROM Ticket
INNER JOIN Customer ON Ticket.CustomerID = Customer.CustomerID
ORDER BY Ticket.SiteHomeLocation, Ticket.TicketID
Run Code Online (Sandbox Code Playgroud)
但是我知道这是非常错误的.有人可以指点我正确的方向吗?我需要在最终的Select中访问程序中的所有列(加入?).该过程中的SQL代码相当痛苦,因此首先是它的原因!
请建议我在哪里需要更新/重构代码以摆脱异常.我尝试使用以下代码解密加密字符串时出现异常.
以下行抛出异常
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
// Read the decrypted bytes from the decrypting stream
// and place them in a string.
plaintext = srDecrypt.ReadToEnd();
}
public string EncryptAuthenticationTokenAes(string plainText)
{
byte[] encrypted;
// Create an AesManaged object
// with the specified key and IV.
using (AesManaged aesAlg = new AesManaged())
{
// Create a decrytor to perform the stream transform.
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
aesAlg.Padding = PaddingMode.None;
// Create the streams used for encryption.
using …Run Code Online (Sandbox Code Playgroud) 我的 WPF 应用程序中有一个TreeViewand Canvas。我正在尝试实现用户可以拖动 TreeViewItem 的功能,并且当用户放在画布上时应该调用一个方法,将 TreeViewItem 标头作为参数传递给该方法。
这是我到目前为止所做的:
private void TreeViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.Source.GetType().Name.Equals("TreeViewItem"))
{
TreeViewItem item = (TreeViewItem)e.Source;
if (item != null)
{
DataObject dataObject = new DataObject();
dataObject.SetData(DataFormats.StringFormat, item.Header.ToString());
DragDrop.DoDragDrop(item, dataObject, DragDropEffects.Copy);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我拖放到画布上时,什么也没有发生。因此,我不确定接下来应该做什么。我觉得它真的很小,但我不知所措。如何调用该方法并检测标头是否已删除?
有任何想法吗?
我正在尝试使用Qt5.1.1访问mysql,但我收到错误错误如下.我也在谷歌搜索了很多但无法解决它.请给我一个解决方案,以便我能够解决这个错误.
错误:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3
QSqlError(-1, “ driver not loaded”, “ driver not loaded”)
Run Code Online (Sandbox Code Playgroud)
码:
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QtSql>
#include <QSqlDriver>
#include <qsqldatabase.h>
#include <QSqlError>
#include <QPluginLoader>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db= QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("NNF");
db.setUserName("root");
db.setPassword("root123");
if( !db.open() )
{
qDebug() << db.lastError();
qFatal( "Failed to connect." );
}
qDebug( "Connected!" );
return a.exec();
}
Run Code Online (Sandbox Code Playgroud) 所以我有一个字符串,我正在变成一个数组,但我想用正则表达式分隔每个单词.我使用下面的函数匹配整个单词.
function substr_count_array($haystack, $needle)
{
$initial = 0;
$bits = explode(' ', $haystack);
foreach ($needle as $substring)
{
if (!in_array($substring, $bits))
{
continue;
}
$initial += substr_count($haystack, $substring);
}
return $initial;
}
Run Code Online (Sandbox Code Playgroud)
问题是它匹配字符串animal,但不是animals.如果我像这样做部分匹配:
function substr_count_array2($haystack, $needle)
{
$initial = 0;
foreach ($needle as $substring)
{
$initial += substr_count($haystack, $substring);
}
return $initial;
}
Run Code Online (Sandbox Code Playgroud)
它也匹配,a因为它包含了单词animals和返回2.如何explode()使用正则表达式作为分隔符,以便我可以匹配每个长度为5-7个字符的字符串?
解释得更简单:
$animals = array('cat','dog','bird');
$toString = implode(' ', $animals);
$data = array('a');
echo substr_count_array($toString, …Run Code Online (Sandbox Code Playgroud) 我的目标是在WPF窗口上绘制图像"someImage.png",它是嵌入式资源,在重写的OnRender方法中:
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
base.OnRender(drawingContext);
drawingContext.DrawImage(ImageSource, Rect);
}
Run Code Online (Sandbox Code Playgroud)
我找到了将我的图像从资源转换为Stream的代码:
public BitmapSource GetSourceForOnRender()
{
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream myStream = myAssembly.GetManifestResourceStream("KisserConsole.someImage.png");
// What to do now?
return //BitmapSource
Run Code Online (Sandbox Code Playgroud)
}
但是我现在如何获得或创建BitmapSource?
这是我的Button声明,用.xaml文件编写:
<dxlc:LayoutGroup Orientation="Horizontal" Margin="5,15,0,5">
<Grid MinWidth="100">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button
IsEnabled="{Binding IsSearchCriteriaHasValue}"
Content="Search"
MaxHeight="25"
MaxWidth="70"
ClipToBounds="True"
VerticalAlignment="Center"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Command="{Binding SearchCommand}"/>
</Grid>
</dxlc:LayoutGroup>
Run Code Online (Sandbox Code Playgroud)
这是返回true/false的函数,无论用户是否在搜索按钮旁边的搜索框中键入了任何搜索文本.该函数位于另一个.cs文件中:
public bool isButtonEnabled
{
return (SearchBox.Selection.Count > 0);
}
Run Code Online (Sandbox Code Playgroud)
问题是isEnabled的值永远不会改变,它保持为真,即按钮始终保持启用状态,或者如果我更改>符号,按钮始终处于禁用状态.有什么建议?
我有一个QML对象定义如下:
Item {
property alias source: a.internalImage.source
property alias text: a.internalText.text
Column {
id: a
Image {
id: internalImage
}
Text {
id: internalText
width: internalImage.width
}
}
}
Run Code Online (Sandbox Code Playgroud)
失败,原因:Invalid alias target location: internalImage。
但是,如果我这样做:
Column {
property alias source: internalImage.source
property alias text: internalText.text
Image {
id: internalImage
}
Text {
id: internalText
width: internalImage.width
}
}
Run Code Online (Sandbox Code Playgroud)
这是为什么?
我正在寻找一个wpf控件(免费或商业).树应支持所有常规树视图特性(样式,数据模板,控件模板......),并支持使用Columns布局(类似于Visual Studio中的Watch窗口).
但是也:
我不想自己构建树,我正在寻找现有的实现,至少支持虚拟化和数据虚拟化.
对于下面的xml,我需要更换<studentStatus>为<studentName>CLASSA</studentName>到<studentStatus>failed</studentStatus>.
<studentFile>
<student>
<studentName>CLASSA</studentName>
<studentStatus>Success</studentStatus>
<studentActions>
<studentAction>
<studentType>Juniour</studentType>
<studentStatus>Completed</studentStatus>
<studentMsg/>
</studentAction>
<studentAction>
<studentType>HighSchool</studentType>
<studentStatus>Completed</studentStatus>
<studentMsg/>
</studentAction>
</studentActions>
</student>
<student>
<studentName>CLASSB</studentName>
<studentStatus>Success</studentStatus>
<studentActions>
<studentAction>
<studentType>Senior</studentType>
<studentStatus>Completed</studentStatus>
</studentAction>
<studentAction>
<studentType>Middle</studentType>
<studentStatus>Completed</studentStatus>
</studentAction>
</studentActions>
</student>
</studentFile>
Run Code Online (Sandbox Code Playgroud)
到目前为止我得到了什么,
xmllint -xpath "/studentFile/student[studentName='CLASSA']/studentActions/studentAction[studentType="Juniour"]/studentStatus" myxml.xml
Run Code Online (Sandbox Code Playgroud)
现在我将学生的状态视为已完成,现在此值应更改为失败.仅限于<studentType>Juniour</studentType>.我应该如何编辑xml以获得它,
<studentFile>
<student>
<studentName>CLASSA</studentName>
<studentStatus>Success</studentStatus>
<studentActions>
<studentAction>
<studentType>Juniour</studentType>
<studentStatus>Failed</studentStatus>
<studentMsg/>
</studentAction>
<studentAction>
<studentType>HighSchool</studentType>
<studentStatus>Completed</studentStatus>
<studentMsg/>
</studentAction>
</studentActions>
</student>
<student>
<studentName>CLASSB</studentName>
<studentStatus>Success</studentStatus>
<studentActions>
<studentAction>
<studentType>Senior</studentType>
<studentStatus>Completed</studentStatus>
</studentAction>
<studentAction>
<studentType>Middle</studentType>
<studentStatus>Completed</studentStatus>
</studentAction>
</studentActions>
</student>
</studentFile>
Run Code Online (Sandbox Code Playgroud)
可以使用sed完成.我知道有像xsltproc这样的工具但不确定它是否安装在我们集群的所有节点中. …