C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

datatable insertion..


Posted Date: 22 Nov 2008      Posted By: gopal      Member Level: Gold     Points: 1   Responses: 1



hi friends..

how to insert values to a datatable during run time..

i am doing this in windows application...

i want coding for in vb..

urgent..

thanx..
gopal





Responses

Author: Yousuf    22 Nov 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 6

hi

This code might help u

Public Shared Function GetConnection()
Dim myConnection As String
myConnection = "Database=qasion;Data Source=localhost;User Id=root;Password=root"
'getGetconnection = ConfigurationManager.ConnectionStrings("").ConnectionString
Return myConnection
End Function

Public Function Insert(ByVal StrQuery As String) As Integer
Dim con As New MySqlConnection(GetConnection().ToString)
Dim cmd As New MySqlCommand(StrQuery, con)
Dim objtrans As MySqlTransaction
Dim intAffectRows As Integer
Try
'objtrans = con.BeginTransaction
With cmd
.Connection.Open()

intAffectRows = .ExecuteNonQuery()
If intAffectRows <= -1 Or 0 Then
cmd.Transaction.Rollback()
.Connection.Close()
End If

'objtrans.Commit()
' .Connection.Close()
End With

If intAffectRows < 0 Then
cmd.Transaction.Rollback()
Else
Return intAffectRows
End If
Catch ex As Exception
Throw ex
End Try
End Function



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Deployment Problem
Previous : Difference
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use