我该如何解决这个问题?我是否缺少我的代码或功能代码?
这是我的C#代码
public int AddDetails(string business, string clerkid, string serverid, string ticket, string tablenumber,
string sourcecard, string recipientcard, DateTime datesaved, string status)
{
CreateConnection();
int dbId = 0;
using(cmd = new MySqlCommand())
{
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "AddDetails";
cmd.Parameters.AddWithValue("m_business", business);
cmd.Parameters.AddWithValue("m_clerkid", clerkid);
cmd.Parameters.AddWithValue("m_serverid", serverid);
cmd.Parameters.AddWithValue("m_ticket", ticket);
cmd.Parameters.AddWithValue("m_tablenumber", tablenumber);
cmd.Parameters.AddWithValue("m_sourcecard", sourcecard);
cmd.Parameters.AddWithValue("m_recipientcard", recipientcard);
cmd.Parameters.AddWithValue("m_datesaved", datesaved);
cmd.Parameters.AddWithValue("m_status", status);
cn.Open();
//dbId = Convert.ToInt32(cmd.LastInsertedId);
dbId = int.Parse(cmd.ExecuteScalar().ToString());
//dbId = Convert.ToInt32(cmd.ExecuteNonQuery());
cn.Close();
}
return dbId;
}
这是我的存储函数
CREATE DEFINER=`root`@`192.168.21.%` FUNCTION `AddDetails`(
m_business VARCHAR(1),
m_clerkid VARCHAR(45),
m_serverid VARCHAR(45),
m_ticket VARCHAR(45),
m_tablenumber VARCHAR(45),
m_sourcecard VARCHAR(45),
m_recipientcard VARCHAR(45),
m_datesaved DATETIME,
m_status VARCHAR(45)
) RETURNS int(11)
READS SQL DATA
BEGIN
INSERT INTO `tbl_merchantwarehouse_transaction`
(
`business`,
`clerkid`,
`serverid`,
`ticket`,
`tablenumber`,
`sourcecardnumber`,
`recipientcardnumber`,
`datesaved`,
`status`
)
VALUES(
m_business,
m_clerkid,
m_serverid,
m_ticket,
m_tablenumber,
m_sourcecard,
m_recipientcard,
m_datesaved,
m_status
);
RETURN LAST_INSERT_ID();
END
对我的代码提出任何建议、建议/改进将不胜感激。谢谢:D
最佳答案
您应该在命令中指定返回参数,例如:
cmd.Parameters.Add("@ireturnvalue", MySqlDbType.Int32);
cmd.Parameters["@ireturnvalue"].Direction = ParameterDirection.ReturnValue;
关于c# - 尝试调用存储函数 "dbname"."functionname"w/o 指定返回参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15737935/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re