
\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{datatool}

\begin{document}

\DTLnewdb{test}
\DTLnewrow{test}%
\DTLnewdbentry{test}{lastname}{fischer}
\DTLnewdbentry{test}{firstname}{ulrike}


%\csname lastname\endcsname
\let\lastname\relax

\DTLforeach{test}{%
 \lastname=lastname,\firstname=firstname}
 {\lastname, \firstname}


\end{document}