Click here to Skip to main content
12,449,440 members (61,020 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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 20-Sep-12 20:53pm
Code-Hunt7.1K
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.
snehasish nandy 21-Sep-12 3:13am
   
Please tell me what more u want..
Ganesh Nikam 21-Sep-12 4:41am
   
your code please
Ervin Pacibe 23-Sep-12 23:50pm
   
your sql query pls
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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...
  Permalink  
Comments
snehasish nandy 21-Sep-12 3:43am
   
please tell me how to write the try catch block..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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...
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100