Outils pour utilisateurs

Outils du site


access_2007

*Accès a une base access 2007 au format .accdb

Téléchargement du composant access 2007 pour connexion ADO http://www.microsoft.com/en-us/download/confirmation.aspx?id=23734

Source ADO chaîne de connexion

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\fabrice.EZGED\Desktop\ADMOK\ADMOK.accdb;Persist Security Info=False

Exemple de code

#ouverture de la base 
try:
	pythoncom.CoInitialize()
	accdb = win32com.client.gencache.EnsureDispatch('ADODB.Connection')
	vpath = "C:\\Users\\fabrice.EZGED\\Desktop\\ADMOK\\ADMOK.accdb"
	accdb.Open("Provider='Microsoft.ACE.OLEDB.12.0';Data source='"+vpath+"';Persist Security Info=False;")
except pythoncom.com_error, error:
	db_errormsg = str(error[2][2].encode("latin1"))
	return -1, "not connected "+db_errormsg

result = win32com.client.Dispatch(r'ADODB.Recordset')
vquery="select Nom, Prénom, Code from Elèves'"
result.Open(vquery,accdb,1,3)
if result <> None:
	while not result.EOF:
		vrow = result.Fields
		
		print vrow[0].Value.encode("latin1"),vrow[1].Value.encode("latin1"),str(vrow[2].Value)
		
		result.MoveNext()
	
	result.Close()
	
accdb.Close()
access_2007.txt · Dernière modification: 2023/03/17 09:56 (modification externe)