我想使用union all with manual value,而不是来自另一个表.价值观是:
|cSatuan1|cSatuan2|nkonversi|
=============================
| LTR | PCS | 1 |
| PCS | LTR | 1 |
Run Code Online (Sandbox Code Playgroud)
我用自己的方式进行了查询,但是它出错了.这是查询:
SELECT csatuan2, csatuan1, nkonversi
FROM ms_metriks union all select 'LTR','PCS','1','PCS','LTR','1'
Run Code Online (Sandbox Code Playgroud)
你能告诉我我的查询有什么问题吗?什么是正确的查询?
我试图将一行数据库中的一行复制到另一台服务器上的另一个数据库,这里是查询:
set identity_insert ms_tpl on
INSERT ms_tpl select * from [10.24.0.2].[MILKP].[dbo].[ms_tpl] where [id] = 3076
set identity_insert ms_tpl off
Run Code Online (Sandbox Code Playgroud)
当我按下F5时,我收到如下错误信息:
Msg 8101,Level 16,State 1,Line 3
只有在使用列列表且IDENTITY_INSERT为ON时,才能指定表'ms_tpl'中标识列的显式值.
我的查询中有错误吗?如何解决这个问题呢?
更多信息:在数据库上ms_tpl,有一列调用id自动增量.
谢谢
我已经声明并设置了一些变量.然后我想在执行存储过程时使用该变量值作为参数.但我总是得到错误
必须声明标量变量.
这是我的变量:
--declare variables for parameter @listweek
declare @tgl_other varchar(50);
--set variables for parameter @listweekset
set @tgl_other = (select top 1 ltrim(rtrim(cast(numweek as char)))+'-('+rangeweek+')' from tbl_weeklyflash where year(dates) = year(getdate()) order by numweek desc);
--the variable values should be like this 30-(01-03-2012 - 08-03-2012)
--and this value that I want to use as parameter value in executing stored procedure
Run Code Online (Sandbox Code Playgroud)
这是执行存储过程:
insert into my_table (field1, field2, field3)
EXEC my_store_procedure @tgl_other
-- the parameter for my_store_procedure is like '30-(01-03-2012 - 08-03-2012)' …Run Code Online (Sandbox Code Playgroud) 我用PHP创建了与mySQL数据库的数据库连接.它工作正常.现在,我想使用先前MySQL数据库中的相同表将该连接更改为MS SQL Server数据库.
这是代码:
config.php
<?php
/**
* Database config variables
*/
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("DB_DATABASE", "android_api");
?>
Run Code Online (Sandbox Code Playgroud)
DB_Connect.php
<?php
class DB_Connect {
// constructor
function __construct() {
}
// destructor
function __destruct() {
// $this->close();
}
// Connecting to database
public function connect() {
require_once 'include/config.php';
// connecting to mysql
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
// selecting database
mysql_select_db(DB_DATABASE);
// return database handler
return $con;
}
// Closing database connection
public function close() {
mysql_close();
} …Run Code Online (Sandbox Code Playgroud) 我用JSON创建了一个Web服务,我想解析它然后把它们放在listview上.但是当我运行应用程序时,它强制关闭并显示错误消息.请查看我的代码,有什么问题吗?
当我尝试运行我的应用程序时,这是错误消息:
org.json.JSONException: Value <?xml of type java.lang.String cannot be converted to JSONObject
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
public class WeeklyFlashActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listplaceholder);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
JSONObject json = JSONfunctions.getJSONfromURL("http://www.greenfields.co.id:502/Service1.svc/json/weeklyflash");
try{
JSONArray weeklyflash = json.getJSONArray("GetReportResult");
for(int i=0;i<weeklyflash.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = weeklyflash.getJSONObject(i);
//map.put("type", String.valueOf(i));
map.put("type", e.getString("type"));
map.put("total", e.getString("total"));
mylist.add(map);
}
}catch(JSONException e) {
Log.e("log_tag", "Error parsing …Run Code Online (Sandbox Code Playgroud) 我想用Gson来解析我的JSON,我已经将Gson库添加到我的项目中.编译它时一切都很好,但是当我运行它时,我得到错误消息日志说
Could not find class 'com.google.gson.Gson', referenced from method report.weeklyflash.WeeklyFlashIdActivity.onCreate
Run Code Online (Sandbox Code Playgroud)
这是使用Gson的代码:
import com.google.gson.Gson;
import report.weeklyflash.ReportResult;
import report.weeklyflash.ReportResults;
public class WeeklyFlashIdActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_item);
System.out.println("oncreate");
final TableLayout tableLayout = (TableLayout) findViewById(R.id.headerTable);
InputStream is = null;
String json = "";
//http get content
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://10.80.3.73/webservice/Service1.svc/json/weeklyflash/my");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}
catch(Exception e)
{
Log.e("log_tag", "Error in http …Run Code Online (Sandbox Code Playgroud)