UNPIVOT在MS SQL Server 2005中可用,但AFAIK不在MS Access 2010中.如何使用板载方式实现?例如,我有一张桌子
ID | A | B | C | Key 1 | Key 2 | Key 3
---------------------------------------
1 | x | y | z | 3 | 199 | 452
2 | x | y | z | 57 | 234 | 452
Run Code Online (Sandbox Code Playgroud)
并希望有一个像这样的表
ID | A | B | C | Key
--------------------
1 | x | y | z | 3
2 | x | y | z | 57
1 …Run Code Online (Sandbox Code Playgroud) 我有一些访问SQL Server 2005的Java代码,如下所示:
CallableStatement cstmt = ...;
... // Set input parameters
cstmt.registerOutParameter(11, Types.INTEGER);
cstmt.execute();
int out = cstmt.getInt(11);
Run Code Online (Sandbox Code Playgroud)
从最后一行抛出以下异常:
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set
for the parameter number 0.
at com.microsoft.sqlserver.jdbc.SQLServerException.
makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
skipOutParameters(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getOutParameter(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getterGetParam(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.
getInt(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedCallableStatement.
getInt(WrappedCallableStatement.java:192)
Run Code Online (Sandbox Code Playgroud)
被调用的存储过程看起来像这样:
CREATE PROCEDURE dbo.stored_proc ( -- 10 input parameters
, @out_param INT OUTPUT) AS
-- Variable declarations
SET @out_param = 0
-- Do processing...
SET @out_param …Run Code Online (Sandbox Code Playgroud) 我正在使用VBA维护用Microsoft Access编写的应用程序.
我正在浏览我的代码并且刚刚注意到我已经下意识地将字符串与加号(+)符号连接在一起而不是符号.我用VB6编写代码已经有几年了.这会导致任何问题吗?
一切似乎都很好,只需要几分钟就可以解决,我只是好奇我是否在技术上做错了什么.
我的mysql db的jdbc驱动程序是版本5.1.25.
我想像这样执行sql查询:
statement.execute("select fullName from user where user_id=1; select fullName from user where user_id=2");
Run Code Online (Sandbox Code Playgroud)
我总是收到异常:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select fullName from user where user_id=2' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809) …Run Code Online (Sandbox Code Playgroud) 我有一个表格,显示每个"AREA"的"DONE"和"REMAIN",如下所示:
AREA DONE REMAIN TOTAL
AREA1 100 200 300
AREA2 200 300 500
AREA3 200 700 900
Run Code Online (Sandbox Code Playgroud)
现在我想用饼图在每个区域制作一个显示"DONE"和"REMAIN"的报告,现在我有问题如何为图表做这个工作,应该如何成为图表控件的"行源".这张桌子需要什么查询?
我试图使用StDev函数,并得到空白结果.我用它作为......
SELECT StDev(fldMean) FROM myTable
Run Code Online (Sandbox Code Playgroud)
其中fldMean包含值2.3并且应该计算为0但是我只是得到一个空结果.我似乎无法理解如何在函数中使用表达式,微软的手册确实无济于事.
有没有办法使用Windows身份验证连接到MS SQL Server ,即使没有在Windows框上运行python应用程序?
我试图用pymssql做这个,但是这些例子似乎主要假设你在windows上运行.
如果有一种方法可以使用其他库来建立这种连接,请随时提出建议,但我确实喜欢pymssql如何通过pip安装和部署.
我想连接到2005/2008数据库,我正在运行Ubuntu 13.04(但如果有所不同,我可以升级到更高版本的Ubuntu)
解:
事实证明,pymssql可以通过我的Windows用户名和密码连接到我的数据库.但要这样做,我需要传递实际的用户名/密码,如下所示:
pymssql.connect(host, 'THEDOMAIN\\theusername', 'thepassword', db)
Run Code Online (Sandbox Code Playgroud)
EkoostikMartin提供的解决方案仍然很好(如果你不想在某个地方存储密码,这可能是windows auth的意思)
我要导入CSV和TXT文件.我将文件导入Access,然后将记录插入到链接的Oracle表中.每个文件大约有300万行,这个过程需要很长时间才能完成.
导入Access非常快,但插入链接的Oracle表需要很长时间.
这是我目前使用的过程:
DoCmd.TransferText acImportFixed, "BUSSEP2014 Link Specification", "tblTempSmartSSP", strFName, False
db.Execute "INSERT INTO METER_DATA ([MPO_REFERENCE]) SELECT MPO_REFERENCE FROM tblTempSmartSSP;"`
Run Code Online (Sandbox Code Playgroud)
tblTempSmartSSP是一个访问表,METER_DATA是一个链接的Oracle表
我也试过直接导入到链表,这也很慢.
我怎样才能加快这个过程?
我尝试了以下方法:
private String password = "";
private String dbName = "dataHC.accdb";
private String bd = dbName + ";PWD=" + password;
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+bd+";";
private Connection conn = null;
//Connect
public void connect() {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url);
if (conn != null)
System.out.println("Conexión a base de datos "+dbName+". listo");
}catch(SQLException e){
System.out.println(e);
}catch(ClassNotFoundException e){
System.out.println(e);
}
}
Run Code Online (Sandbox Code Playgroud)
字体:http://www.jc-mouse.net/base-de-datos/consultas-con-parametros-en-access-y-java
我得到了这个错误:
[Microsoft] [ODBC Microsoft Access驱动程序]常规错误无法打开注册表项临时(易失性)Ace DSN进程0x7f8线程0x1174 DBC
特别
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]General error …Run Code Online (Sandbox Code Playgroud)