编码部分错误. [英] error in coding part.

查看:82
本文介绍了编码部分错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cmd = new SqlCommand(candintrest, cn);
 cmd.CommandText = candintrest;
 int interestid = (int)cmd.ExecuteScalar();    *****error specify on this line***


错误发生:-


Error Occure:-

System.Data.SqlClient.SqlException: Incorrect syntax near ',' 


请尝试解决它.​​


plz try to solve it.

推荐答案

我认为一旦检查您的quary(candintrest),您的quary中就有错误

例如:对于插入类查询
I think In your quary has error once check your quary(candintrest)

ex:For Insert Quary
create procedure like
Create PROCEDURE dbo.StoredProcedure1(@id int,@name varchar(50),@addr varchar(50))
	/*
	(
	@parameter1 int = 5,
	@parameter2 datatype OUTPUT
	)
	*/
AS
begin
insert into sample (id,name,address) values(@id,@name,@addr)
	/* SET NOCOUNT ON */
	end



在后面的代码中:



in code behind:

con = New SqlConnection(ConfigurationManager.ConnectionStrings("con").ConnectionString)  
        cmd = New SqlCommand()
        If con.State = ConnectionState.Closed Then
            con.Open()
        End If
        cmd.Connection = con
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "StoredProcedure1"
        cmd.Parameters.AddWithValue("@id", TextBox1.Text)
        cmd.Parameters.AddWithValue("@name", TextBox2.Text)
        cmd.Parameters.AddWithValue("@addr", TextBox3.Text)


        Dim i As Integer

        i = cmd.ExecuteNonQuery()
        If (i >= 1) Then
            Response.Write("sucess")
        Else
            Response.Write("Fail")
        End If
        con.Close()


您好,这对您有帮助.....

只保留行情
Hello This will be helpful to you..........

Just keep Quotes
cmd = new SqlCommand("candintrest", cn);


请检查查询中所有的"和"以及和+符号"
Please check all '' and , and " and + symbols in your query


这篇关于编码部分错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆