473,614 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

command.Command Timeout

2 New Member
Can someone please help me? I have class for database connection and I need set command.command Timeout. How can I do that?

Code:
Imports System.Data.Sql Client
Imports System.Data
Public Class Db
Private Shared _ConnString As String = ""
Private Shared _Connection As SqlConnection

Public Shared Sub SetConnectionSt ring(ByVal connString As String)
_ConnString = connString
End Sub

Public Shared Function GetReader(ByVal sqlStatement As String, ByVal params() As Object) As SqlDataReader
OpenConnection( )
Dim command As SqlCommand
command = FillParams(sqlS tatement, params)
Return command.Execute Reader(CommandB ehavior.CloseCo nnection)
End Function

Public Shared Function GetDataSet(ByVa l sqlStatement As String) As DataSet
Dim retDs As New DataSet
OpenConnection( )
Dim ad As New SqlDataAdapter( sqlStatement, _Connection)
ad.Fill(retDs)
_Connection.Clo se()
Return retDs
End Function

Public Shared Function Exec(ByVal sqlStatement As String, ByVal params() As Object, ByVal maOutput As Boolean) As ArrayList
Dim ret As ArrayList = New ArrayList
OpenConnection( )
Dim command As SqlCommand

command = FillParams(sqlS tatement, params)
command.Execute NonQuery()
For Each p As SqlParameter In command.Paramet ers
If p.Direction = ParameterDirect ion.InputOutput Or p.Direction = ParameterDirect ion.Output Then
Try
ret.Add(p.Value )
Catch : End Try
End If
Next
Return ret
End Function

Public Shared Function execCom(ByVal sqlStatement As String, ByVal params() As Object) As Int32
OpenConnection( )
Dim command As SqlCommand

command = FillParams(sqlS tatement, params)

Return command.Execute NonQuery()
End Function

Private Shared Function FillParams(ByVa l sqlStatement As String, ByVal params() As Object) As SqlCommand
Dim command As New SqlCommand(sqlS tatement, _Connection)


If Not params Is Nothing Then
Dim i As Int16
For i = 0 To params.Length - 1
command.Paramet ers.Add(CType(p arams(i), SqlParameter))
Next
End If
Return command
End Function

Private Shared Sub OpenConnection( )
If _Connection Is Nothing Then
_Connection = New SqlConnection(_ ConnString)
End If

If Not _Connection.Sta te = ConnectionState .Open Then
_Connection.Ope n()
Else
_Connection.Clo se()
_Connection.Ope n()
End If
End Sub


End Class
Sep 3 '07 #1
0 1697

Sign in to post your reply or Sign up for a free account.

Similar topics

4
11530
by: Cath B | last post by:
I am pretty sure I am getting a command timeout when execute a SQL procedure that has an output parameter. The code below is in an asp page that is called using RSGetASPObject. I want to be able to send a message back to the calling page to indicate that a timeout has occurred, but am having a hard time capturing the timeout error. I intend to set the timeout parameters so that I don't get timeout errors, but in the case that I would I...
2
10740
by: Tahir Khan | last post by:
I am running into a command time out error. I have to retrieve a lot of date thru a complex query. For some reason, I can't change the commandtimeout to more then 30 secs. And yes I have Connectiontime incr4eased to 90 seconds. No luck. Is there some thing about ADO version that could help? Here is the string that I use to make the connection. server.scripttimeout = 80 set srs = Server.CreateObject("ADODB.RecordSet")
1
11580
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like Account Additional, Sale_Additional so most tables stay the same. The latest restored database (I'll call it DBaseA) is behaving differently in VB6 code and I need help trying to make it work. I have been using use an ADODB.Command to execute...
1
8391
by: Craig Thompson | last post by:
Does anyone know of a way to set the Command TimeOut when you are using the DAAB? Am I going to have to modify DAAB code to accept a new parameter?... BTW, setting the connection timeout in the connection string doesn't help my problem. Thanks, Craig
12
9783
by: Piotrek | last post by:
HI all. In my web site I have some ObjetDataSource. Its business object property is set to my dataset I created in dataset designer (this dataset has table adapter). My question is: how can I set command timeout property for fill method from this table adapter? Thanks in advance,
2
1765
by: Mangler | last post by:
I a running a SP and calling it through ASP. I keep getting this error: Parameter object is improperly defined. Inconsistent or incomplete information was provided. I think I have the format of the date wrong somewhere. Can someone help?
2
7958
by: John Kotuby | last post by:
Hi all, I have set up a page with a Repeater and a SQLDatasource control, the data control suggested by online Help for use with the Repeater. I am getting Timeout Expired after 30 seconds. I expect many of my queries to take longer than 30 seconds because they are ad hoc user-defined searches through multiple joined tables and associated Text fields. I have to learn more about creating full text indexes for searching...but. How can I...
0
1516
by: czerwww | last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that? Code: Imports System.Data.SqlClient Imports System.Data Public Class Db Private Shared _ConnString As String = "" Private Shared _Connection As SqlConnection Public Shared Sub SetConnectionString(ByVal connString As String)
1
1965
by: Leon Mayne | last post by:
Hello, I had a chunk of code that would execute a stored proc to migrate data between two systems (takes a few minutes) and then performs some data manipulation on the migrated data. This was working fine when I was using SqlCommand.CommandTimeout = 0. After getting the basics to work I wanted to wrap the whole block in a transaction to roll back everything if something went wrong: Dim cnMigrate As New SqlConnection(pConnectionString)
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5548
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.