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
Today
    Last 7 Days more...






    Forums » .NET » .NET »

    How to create -- very very urgent


    Posted Date: 03 Jul 2009      Posted By: Sravya      Member Level: Gold     Points: 1   Responses: 4



    Running SQL Script from Vb.net program ??
    Running SQL Script from Vb.net program ??
    Running SQL Script from Vb.net program ??

    if i run the sql sript from the vb.net program it should execute the script and create the things which are in the script

    for table script
    for SPs sript

    Please anybudy urgent

    Thanks in advance





    Responses

    Author: Milind Kansagara    03 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

    you can make one procedure and execute that procedure using vb .net here i am providing how to call procedure example in c# you can convert his to VB .net just syntactical difference will be there
    Database objDatabase = DatabaseFactory.CreateDatabase();
    DbCommand objDbCommand = objDatabase.GetStoredProcCommand("usp_Testimonial_List");

    objDatabase.AddInParameter(objDbCommand, "@TestimonialID", DbType.Int32, this.TestimonialID);

    DataSet dsTestimonialList = objDatabase.ExecuteDataSet(objDbCommand);

    return dsTestimonialList.Tables[0].Rows.Count > 0 ? dsTestimonialList.Tables[0].Rows[0] : null;

    Regards,
    Milind Kansagara
    Web Developer (Cybercomcreation)
    Ahmedabad.
    http://milindkansagara1984.blogspot.com



    Author: Nikhil Gaur    03 Jul 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

    use this resource on DNS

    http://www.dotnetspider.com/resources/29151-Use-SQL-stored-procedure-ADO-NET-code.aspx

    Join this campus group
    http://www.dotnetspider.com/sites/637/-ecb-aspdotnet.aspx

    Thanks & Regards
    NIks
    My Software and Web Development Experience



    Author: Ramesh S    03 Jul 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

    Try this


    Public Overrides Sub Execute_SqlScript(ByVal fileName As String, ByVal database As String)

    Dim sr As StreamReader = Nothing

    Dim sb As StringBuilder = Nothing

    Dim line As String = ""

    Try

    Command_Type = CommandType.Text

    Command_Create()

    Connection_Open()

    Transaction_Begin()

    sr = New StreamReader(fileName)

    Do

    sb = New StringBuilder

    Do

    line = sr.ReadLine()

    If (line = "GO" Or line Is Nothing) Then Exit Do

    sb.Append(ControlChars.CrLf & line)

    Loop

    If line Is Nothing Then Exit Do

    objSQLCommand.CommandText = sb.ToString

    objSQLCommand.ExecuteNonQuery()

    Loop Until line Is Nothing

    If Me.Transaction_Exists Then Me.Transaction_Commit()

    Catch ex As Exception

    Transaction_Rollback()

    Throw New aExceptions.BespokeException(ex, _

    aExceptions.BespokeException.enmType.SERVER_SQLERROR, _

    "MSSQL2005: Execute_SqlScript(2)")

    Finally

    If sr IsNot Nothing Then sr.Close()

    Reset()

    End Try

    End Sub



    Thanks & Regards
    Ramesh. S
     
    My Articles & Resources at DNS



    Author: Mohsin    04 Jul 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

    Public Overrides Sub Execute_SqlScript(ByVal fileName As String, ByVal database As String)

    Dim sr As StreamReader = Nothing

    Dim sb As StringBuilder = Nothing

    Dim line As String = ""

    Try

    Command_Type = CommandType.Text

    Command_Create()

    Connection_Open()

    Transaction_Begin()

    sr = New StreamReader(fileName)

    Do

    sb = New StringBuilder

    Do

    line = sr.ReadLine()

    If (line = "GO" Or line Is Nothing) Then Exit Do

    sb.Append(ControlChars.CrLf & line)

    Loop

    If line Is Nothing Then Exit Do

    objSQLCommand.CommandText = sb.ToString

    objSQLCommand.ExecuteNonQuery()

    Loop Until line Is Nothing

    If Me.Transaction_Exists Then Me.Transaction_Commit()

    Catch ex As Exception

    Transaction_Rollback()

    Throw New aExceptions.BespokeException(ex, _

    aExceptions.BespokeException.enmType.SERVER_SQLERROR, _

    "MSSQL2005: Execute_SqlScript(2)")

    Finally

    If sr IsNot Nothing Then sr.Close()

    Reset()

    End Try

    End Sub



    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 : internal keyword
    Previous : Windows services
    Return to Discussion Forum
    Post New Message
    Category: .NET

    Related Messages



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use