Controlling blood sugar levels in people with Type 2 diabetes may help prevent dementia, experts have said.
A study of 350,000 people with Type 2 diabetes found poor blood sugar control was associated with hospital admissions for the condition.
Scientists have previously suggested a link between high blood sugar and Alzheimer's disease.
There are 3.3 million people diagnosed with diabetes in the UK, of whom 90% have Type 2, which is linked to obesity.
This figure is expected to rise to five million by 2025, according to Diabetes UK.
The new research found that people with high blood sugar had a 50% higher chance of being admitted to hospital with dementia than those with good control.
The data was taken from the Swedish National Diabetes Registry for the period January 2004 to December 2012.
Type 2 diabetes patients were followed up until hospital admission for dementia or until they died or the study ended.
Experts analysed blood sugar levels as measured by the HbA1c diabetic blood test.
After adjusting for factors that may influence the results, they found that those patients with sugar levels of 10.5% or higher were 50% more likely have dementia than those with a well-controlled level of 6.5% or less.
Of the total group, 11,035 patients (3.2%) were admitted to hospital with a main diagnosis of dementia, or had dementia diagnosed alongside other illnesses.
Those patients who had suffered a stroke previously were 40% more likely to develop dementia than those who had not had a stroke.
The patients were typically aged 67 at the start of the study.
Dr Aidin Rawshani and colleagues presented their findings at the European Association for the Study of Diabetes conference in Stockholm.
They said: "The positive association between HbA1c and risk of dementia in fairly young patients with Type 2 diabetes indicates a potential for prevention of dementia with improved blood sugar control."
Dr Richard Elliott, research communications manager at Diabetes UK, said: "We already know that high blood glucose levels are linked to a higher risk of problems with memory and thinking in people with Type 2 diabetes, which can in turn lead to a higher risk of dementia in later life.
"The exact reasons for this are still unclear, but it is important to manage diabetes carefully in order to reduce the risk of serious complications.
"The best way to do that is to take diabetes medications prescribed by your doctor and to maintain a healthy weight by exercising regularly and eating a healthy balanced diet that is low in salt, fat and sugar."
Dr Doug Brown, director of research and development at the Alzheimer's Society, said: "There is a growing body of scientific evidence that poorly managed Type 2 diabetes increases the risk of dementia.
"This large-scale study adds to it by providing evidence that those with poor blood sugar control are more likely to develop dementia.
"We look forward to seeing the full results of this research as it could have important implications for future public health initiatives."