2015年05月

Access to Excel VBA SQL Join

I have two tables in a database in access and I want to perform CRUD operations from excel vba. Though I was able to perform CRUD into individual tables separately, but it says some JOIN Error while performing CRUD on both the tables at same time.Here are the
Tables &
Relationship between them.
I tried something like this but it says a JOIN Error



"Select CustomerT.First_Name,ProductT.Product_Name,CutomerT.Age From CustomerT Inner Join ProductT ON Customer.ID = ProductT.Customer_ID"


My main aim is to find out the details about the customer ans the product he/she ordered by entering the customer id.
Please suggest what to do.



Here is the full code that I am using



Sub CommandButton1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Access2Excel\DB1.accdb;Persist Security Info=False;"
'Open Db connection
con.Open
Set rs.ActiveConnection = con
rs.Open "Select CustomerT.First_Name,ProductT.Product_Name,CutomerT.Age From CustomerT Inner Join ProductT ON CustomerT.ID = ProductT.Customer_ID "
StartRow = 3
Do Until rs.EOF

'first field
Cells(StartRow, 4) = rs.Fields(0).Value
'second field
Cells(StartRow, 5) = rs.Fields(1).Value
'Third field
Cells(StartRow, 6) = rs.Fields(2).Value


rs.MoveNext
StartRow = StartRow + 1
Loop
Set rs = Nothing
con.Close
Set con = Nothing
End Sub


Answers

there seems to be a T missing in Customer.ID. The join should be like:



Select CustomerT.First_Name,ProductT.Product_Name,CustomerT.Age 
From CustomerT Inner Join ProductT ON CustomerT.ID = ProductT.Customer_ID


Edit:



Also changed CutomerT.Ageto CustomerT.Age, thanks LondonRob!





How do I use cx_Freeze on mac?

I used python 3.4 and cx_Freeze on my mac. I was trying to convert my python script into a stand alone application here is the code I got in my setup.py file:



application_title = "Death Dodger 1.0" 
main_python_file = "DeathDodger-1.0.py"

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
base = "Win32GUI"

includes = ["atexit","re"]

setup(
name = application_title,
version = "1.0",
description = "Sample cx_Freeze PyQt4 script",
options = {"build_exe" : {"includes" : includes }},
executables = [Executable(main_python_file, base = base)])


I typed in these lines of code into my Terminal:



cd /Users/HarryHarlow/Desktop/Death_Dodger


and I typed in this line after:



python3.4 setup.py bdist_mac


I got this error message after long lines of other results:



error: [Errno 2] No such file or directory:       '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl'


Please help, I've been stuck on this for 3 weeks,thank you.



Answers

If you don't need Tcl you can exclude it in the setup file:



application_title = "Death Dodger 1.0" 
main_python_file = "DeathDodger-1.0.py"

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
base = "Win32GUI"

includes = ["atexit","re"]

setup(
name = application_title,
version = "1.0",
description = "Sample cx_Freeze PyQt4 script",
options = {
"build_exe" : {
"includes" : includes
"excludes": ['tcl', 'ttk', 'tkinter', 'Tkinter'],
}
},
executables = [
Executable(main_python_file, base = base)
]
)


I excluded also Tkinter since as far as I can understand you are making use of PyQt4 to draw the user interface.





Docker inspect with unix:///var/run/docker.sock (in Java or Scala)

Docker has lots of interesting information available via unix:///var/run/docker.sock



I have been able to map this to a port and I can access /containers/json with GET requests to the port. But... this is not exactly secure.



How can I access /containers/json from this raw socket file (in Java or Scala)?



Answers

It's not possible to use pure java as there is no framework support for Unix sockets. However, you can use some sort of jni-library for this. Like this one.





How to use session in GUI

Im a beginner. Can i use session to track the person who are using the current application by displaying her id or name? if yes, can someone show me the code for example?



Answers

System.getProperty("user.name") will return the username of the current user as a String.





↑このページのトップヘ