Passing a variable in SED getting command garbled

I fairly new to SED. I have tried many different variations of this line of code and even breaking it down into its components and running them separately.

They work individually without variables but when I place the $todbname variable it will either inserts the text "connect to $todbname" or it will give the command garbled as it has this time.

This is the code that is not working properly
-e '1i\
connect to "$todbname";'

The entire line of code and bourne trace is below.

This results in "connect to $todbname" being inserted on the first line of the file.

sed -e 's/^[ \t]//;s/[ \t]$//' -e '/./,/^$/!d' -e "/$fromdbuser/ s//$todbuser/g" -e '1i\
connect to $todbname;' fk_"$todbname".sql.orig > fk_"$todbname".sql

This results in the command garbeld error.
`sed -e 's/^[ \t]//;s/[ \t]$//' -e '/./,/^$/!d' -e "/$fromdbuser/ s//$todbuser/g" -e '1i\
connect to "$todbname";' fk_"$todbname".sql.orig > fk_"$todbname".sql`

+ sed -e s/^[ \t]//;s/[ \t]$// -e /./,/^$/!d -e /db8inst/ s//db8inst1/g -e 1iconnect to "$todbname"; fk_eldtest.sql.orig
sed: command garbled: 1iconnect to "$todbname";

Can anyone help me?

Thanks,
Eric

-e "1i\
connect to ${todbname};"

If I add

-e "1i\
connect as ${todbname};"

I get this, I now get the "eldtest" string in the ${todbname} but I still get the command garbled error.

+ sed -e s/^[ \t]//;s/[ \t]$// -e /./,/^$/!d -e /db8inst/ s//db8inst1/g -e 1iconnect to eldtest; fk_eldtest.sql.orig
sed: command garbled: 1iconnect to eldtest;

Thanks,
Eric

Fixed it using various quote combinations. I used single for the entire command string, then areound the variable I use single, double, double and single. Now it works.

-e '1i\
connect to '"${todbname}"';' fk_"$todbname".sql.temp > fk_"$todbname".sql

Thanks for time and getting me in the right direction,
Eric