大家帮忙看看小弟我这个有关问题啊

大家帮忙看看我这个问题啊,在线等啊
我在做一个小小的数据库系统,在通过程序建立数据库的时候,需要判断输入的数据库名不能与已有的SQL数据库相同.老是报错,说列名无效..还请大虾们帮忙啊
下面是我的部分代码
sc.Open();(连接到master数据库的)
SqlCommand   cmd=new   SqlCommand();
cmd.Connection=sc;
cmd.CommandText= "select   count(name)   from   sysdatabases     where   name= "+this.txtSJK.Text;
  if((int)cmd.ExecuteScalar()> 0)
{
  MessageBox.Show( "名为 "+this.txtSJK.Text+ "的数据库已经存在,请重新输入数据库名 ");
this.txtSJK.Focus();
return;
    }

------解决方案--------------------
try..

cmd.CommandText= "select count([name]) from sysdatabases where [name]= "+this.txtSJK.Text;
------解决方案--------------------
如果不行,检查下是否有name这一字段..
------解决方案--------------------
sc.Open();
SqlCommand cmd=new SqlCommand();
cmd.Connection=sc;
cmd.CommandText= "select count([name]) from sysdatabases where [name]= ' " + this.txtSJK.Text + " ' ";
if((int)cmd.ExecuteScalar()> 0)
{
MessageBox.Show( "名为 "+this.txtSJK.Text+ "的数据库已经存在,请重新输入数据库名 ");
this.txtSJK.Focus();
return;
}
------解决方案--------------------
貌似引号没加...

把你的sql在查询分析器或SSMS里做一下,确保sql本身没错。

另外catch一下SqlException,看看它报什么错。