HELP! ...with SQL...!

Discussion in 'Databases' started by JEP_Dude, Dec 16, 2009.

  1. #1
    Help!

    I have limited SQL experience from the days when FoxPro was used for DOS and Windows 3.1! So, I have copied an SQL example code from a book and I've made a few modifications.

    I'd like to have two main qiestions answered.
    1 - Will this code work in .Net 3.5?
    2 - How could this SQL code be optimized?

    Here's the code:

    ---------------

    Friend Sub SaveStatistics()
    ' This routine will store the stock symbol & closing price in SQL format.
    ' An ASP.Net program will retrieve SQL file for display.

    Dim ConnectionString As String '= This will be designed with .Net Wizard.

    Dim Con_StockDB As New SqlClient.SqlConnection(ConnectionString)

    Con_StockDB.Open()

    Dim SQL_CMD As New SqlClient.SqlCommand _
    ("INSERT INTO Stock_Status " & "VALUES (?, ?)", Con_StockDB)

    For LIndex = 1 To (G_NIP - G_MissingStock)
    SQL_CMD.Parameters.Add(New SqlClient.SqlParameter _
    ("Symbol", G_StockSymbol(LIndex)))

    SqlClient.SqlParameter("ClosePrice", G_Stock(L_StockIndex).ClosePrice))

    Try
    SQL_CMD.ExecuteNonQuery()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try
    Next LIndex

    Con_StockDB.Close()
    Con_StockDB.Dispose()
    End Sub
     
    JEP_Dude, Dec 16, 2009 IP
  2. yogesh420

    yogesh420 Well-Known Member

    Messages:
    447
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    120
    #2
    1. Yes mostly it will work..
    2. i think this code does not needed to optimize..

    correct me if i am wrong..

    btw y ru using ("INSERT INTO Stock_Status " & "VALUES (?, ?)", Con_StockDB) ??

    ("INSERT INTO Stock_Status VALUES (?, ?)", Con_StockDB) this will work..
     
    yogesh420, Dec 19, 2009 IP
  3. JEP_Dude

    JEP_Dude Peon

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How should I retrieve the contents of this SQL data file with ASP.Net?

    God Bless

    JEP_Dude
     
    JEP_Dude, Dec 24, 2009 IP
  4. AnAnonymous Surf

    AnAnonymous Surf Guest

    Messages:
    313
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    AnAnonymous Surf, Dec 26, 2009 IP
  5. JEP_Dude

    JEP_Dude Peon

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    JEP_Dude, Dec 28, 2009 IP