Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Mehdi Gholam 21-Sep-12 3:09am    
You really have to supply more information since we cannot see your environment or code you are using.
[no name] 21-Sep-12 3:13am    
Please tell me what more u want..
Ganesh Nikam 21-Sep-12 4:41am    
your code please
xErvender 23-Sep-12 23:50pm    
your sql query pls

 
Share this answer
 
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...
 
Share this answer
 
Comments
[no name] 21-Sep-12 3:43am    
please tell me how to write the try catch block..
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...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900