I have a Stored Procedure which when run on SQLServer takes 1 second to run, yet in my VB.Net code it takes nearly 20 seconds. It takes a long time on the line:
Adapter.Fill(ds,"TimeTable")
Am I doing something wrong for it to take so long?
My code snippet is below:
SQLConn = New SqlConnection(SQLDConnString)
cmd = New SqlCommand("SPNAME", SQLConn)
cmd.CommandType = CommandType.StoredProcedure
SQLConn.Open()
cmd.Parameters.AddWithValue("@p1", p1)
cmd.Parameters.AddWithValue("@p2", p2)
cmd.Parameters.AddWithValue("@p3", p3)
cmd.Parameters.AddWithValue("@p4", p4)
adapter.SelectCommand = cmd
adapter.Fill(ds, "TimeTable")
DataGridView1.DataSource = ds.Tables("TimeTable")
SQLConn.Close()