Click here to Skip to main content
16,011,475 members
Home / Discussions / Database
   

Database

 
GeneralHelp with SQL Parameter Pin
~toki18-Sep-02 15:59
~toki18-Sep-02 15:59 
GeneralRe: Help with SQL Parameter Pin
Jon Hulatt18-Sep-02 22:11
Jon Hulatt18-Sep-02 22:11 
GeneralRe: Help with SQL Parameter Pin
Rein Hillmann18-Sep-02 23:02
Rein Hillmann18-Sep-02 23:02 
GeneralRe: Help with SQL Parameter Pin
~toki19-Sep-02 14:01
~toki19-Sep-02 14:01 
GeneralProblem with SQL FETCH Pin
Cheickna18-Sep-02 4:03
Cheickna18-Sep-02 4:03 
QuestionWhy is ADO.NET so slow? Pin
ekk17-Sep-02 6:02
ekk17-Sep-02 6:02 
AnswerRe: Why is ADO.NET so slow? Pin
Nick Parker17-Sep-02 16:51
protectorNick Parker17-Sep-02 16:51 
GeneralRe: Why is ADO.NET so slow? Pin
ekk18-Sep-02 11:45
ekk18-Sep-02 11:45 
He is all of the code... It assumes that there exists an Access db at c:\test.mdb and a SQL db called testSQL on an instance at COMPUTER\SQLServer... The dbs each contain one table named Test, defined by one Date field (Observation) and 40 Single fields (Val1, Val2, ...). The project has a reference to DAO 3.6 Object Library...

Imports System.Data.OleDb
Imports System.Data.SqlClient

Module Module1

    Sub Main()
        Randomize(-1000)
        Dim start As Date = Date.Now
        ExecuteDAO()
        System.Console.WriteLine("DAO output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
        start = Date.Now
        ExecuteOleDb()
        System.Console.WriteLine("OleDb output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
        start = Date.Now
        ExecuteSql()
        System.Console.WriteLine("Sql output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
        System.Console.WriteLine("Press any key to continue...")
        System.Console.Read()
    End Sub

    Public Function ExecuteOleDb()
        Dim conn As OleDbConnection
        Dim cmd As IDbCommand
        Dim i, j As Integer
        conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\test.mdb'")
        conn.Open()
        cmd = CreateCommand(conn)
        For i = 1 To 8760
            cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
            For j = 1 To 40
                cmd.Parameters(j).Value = Rnd()
            Next
            cmd.ExecuteNonQuery()
        Next
        conn.Close()
    End Function
    Public Function ExecuteSql()
        Dim conn As SqlConnection
        Dim cmd As IDbCommand
        Dim i, j As Integer
        conn = New SqlConnection("Data Source=COMPUTER\SQLServer; Database=testSQL; Integrated Security=SSPI")
        conn.Open()
        cmd = CreateCommand(conn)
        For i = 1 To 8760
            cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
            For j = 1 To 40
                cmd.Parameters(j).Value = Rnd()
            Next
            cmd.ExecuteNonQuery()
        Next
        conn.Close()
    End Function
    Public Function ExecuteDAO()
        Dim dbEng As DAO.DBEngineClass = New DAO.DBEngineClass()
        Dim wk As DAO.Workspace = dbEng.Workspaces(0)
        Dim db As DAO.Database = wk.OpenDatabase("C:\test.mdb")
        Dim rs As DAO.Recordset = db.OpenRecordset("Test")
        Dim i, j As Integer
        For i = 1 To 8760
            rs.AddNew()
            rs.Fields(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
            For j = 1 To 40
                rs.Fields(j).Value = Rnd()
            Next
            rs.Update()
        Next
        rs.Close()
        db.Close()
    End Function

    Public Function CreateCommand(ByVal conn As IDbConnection) As IDbCommand
        Dim cmd As IDbCommand = conn.CreateCommand()
        Dim param As IDbDataParameter
        param = cmd.CreateParameter()
        param.ParameterName = "@obs"
        param.DbType = DbType.DateTime
        cmd.Parameters.Add(param)
        Dim cmdText As String = "INSERT INTO Test (Observation"
        Dim cmdTextParams As String = "@obs"
        Dim scen As Integer
        For scen = 1 To 40
            param = cmd.CreateParameter()
            param.ParameterName = "@val" & scen
            param.DbType = DbType.Double
            cmd.Parameters.Add(param)
            cmdText &= ", Val" & scen
            cmdTextParams &= ", @val" & scen
        Next
        cmdText &= ") VALUES (" & cmdTextParams & ")"
        cmd.CommandText = cmdText
        cmd.Prepare()
        Return cmd
    End Function

End Module

GeneralInstallShield - MSAccess Pin
Spiros17-Sep-02 4:16
Spiros17-Sep-02 4:16 
GeneralRe: InstallShield - MSAccess Pin
David Salter17-Sep-02 11:55
David Salter17-Sep-02 11:55 
GeneralRe: InstallShield - MSAccess Pin
Spiros17-Sep-02 16:40
Spiros17-Sep-02 16:40 
GeneralRe: InstallShield - MSAccess Pin
Paul Riley18-Sep-02 12:34
Paul Riley18-Sep-02 12:34 
QuestionHow can I list all available OLE DB providers with C#? Pin
Vu Truong17-Sep-02 0:47
Vu Truong17-Sep-02 0:47 
GeneralWierd ADO problem Pin
James Spibey17-Sep-02 0:39
James Spibey17-Sep-02 0:39 
GeneralRe: Wierd ADO problem Pin
SimonS17-Sep-02 4:20
SimonS17-Sep-02 4:20 
GeneralRe: Wierd ADO problem Pin
James Spibey17-Sep-02 5:18
James Spibey17-Sep-02 5:18 
QuestionList all available OLE DB providers by another way??? Pin
Vu Truong16-Sep-02 23:20
Vu Truong16-Sep-02 23:20 
GeneralGetting the SQL server Locale with ADO Pin
Le centriste16-Sep-02 13:04
Le centriste16-Sep-02 13:04 
GeneralRe: Getting the SQL server Locale with ADO Pin
Richard Deeming17-Sep-02 0:41
mveRichard Deeming17-Sep-02 0:41 
GeneralHELP (search in the image data type) (MSSQL Server) Pin
Archigal16-Sep-02 10:16
Archigal16-Sep-02 10:16 
GeneralAccessing MS SQL-Server via ADO Pin
am_16-Sep-02 3:10
am_16-Sep-02 3:10 
GeneralRe: Accessing MS SQL-Server via ADO Pin
Jon Hulatt16-Sep-02 22:19
Jon Hulatt16-Sep-02 22:19 
GeneralRe: Accessing MS SQL-Server via ADO Pin
am_16-Sep-02 22:38
am_16-Sep-02 22:38 
GeneralRe: Accessing MS SQL-Server via ADO Pin
Jon Hulatt16-Sep-02 23:45
Jon Hulatt16-Sep-02 23:45 
GeneralRe: Accessing MS SQL-Server via ADO Pin
am_17-Sep-02 1:55
am_17-Sep-02 1:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.