SQL查询中的异常

时间:2014-07-16 16:23:31

标签: sql-server vb.net

我试图在数据库表中以字符串形式插入查询。但我得到了一个例外

  

'p101'

附近的语法不正确

代码:

str = "Select cnum,email from empdb,expdb,edu,propdb where ecode=eno and ecode=enumb and pnum=pcode and pcode='p101'"
Dim dialresult As DialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButtons.YesNo)
If dialresult = DialogResult.Yes Then
    ' s = InputBox("Enter a name")
    s = InputBox("en", "save", "titl1")

    com = New SqlCommand("INSERT INTO SaveQuery(qname,fullquery) VALUES ('" + s + "','" + str + "')", con)
    com.ExecuteNonQuery()
    com.Dispose()
End If

0 个答案:

没有答案