在cmd.executenonquery()语句中需要帮助 [英] Need help in cmd.executenonquery() statement

查看:139
本文介绍了在cmd.executenonquery()语句中需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

在控件进入cmd.executenonquery()语句时插入时,应用程序用于挂起和退出. 请告诉我原因..i我正在使用vb.net 2008和sql 2005

Hi all

while insertion when the control is comming to cmd.executenonquery() statement the application use to hang and exit..
please tell me why it is happening..i am using vb.net 2008 and sql 2005

推荐答案

我认为连接时间过长了,请使用CommandTimeout属性设置时间

看到您可能会想到的这些链接
http://forums.asp.net/t/1157123.aspx/1 [ ^ ]
http://www.pcreview.co.uk/forums/oledb-hangs-executenonquery- t3398044.html [ ^ ]
http://forums.asp.net/t/1343831.aspx/1 [ ^ ]
http://www.insidehtml.com/forums/viewConverse.asp?d_id=20661 [ ^ ]
i think connection time is exipired use CommandTimeout property for setting time

see these links you may idea about this
http://forums.asp.net/t/1157123.aspx/1[^]
http://www.pcreview.co.uk/forums/oledb-hangs-executenonquery-t3398044.html[^]
http://forums.asp.net/t/1343831.aspx/1[^]
http://www.insidedhtml.com/forums/viewConverse.asp?d_id=20661[^]


您好,

这个问题是未知的,因此请使用Try catch块,以便在异常情况下我们可能知道未处理的异常. reson可能是sql语句可能是错误.

在您正在使用的sql或数据库中执行sql查询,并检查该语句是否可以正常执行.

SQL连接可能是问题.

编码愉快...
Hi,

the issue is not know so use Try catch block so that in the exception we might come to know the exception which has been unhandeled. the reson might be the sql statement might be an error.

Execute the sql query in the sql or the database your using and check weather the statement is executing fine.

SQL connection might be the problem.

Happy coding...


是的,我们去了,

Yes here we go,

Try
    dim command as string= "Insert into table ("Name") values ("Beem")"
    MyConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("DBO").ConnectionString)
    MyConnection.Open()
    Dim MyCommand As SqlCommand
    MyCommand = New SqlCommand(command, MyConnection)
    MyCommand.ExecuteNonQuery()
    DisposeConnection()
Catch ex As Exception

End Try



尝试一下就是这样....

祝你好运...



this is how it will look like try this....

Good luck...


这篇关于在cmd.executenonquery()语句中需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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