Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Tuesday, March 27, 2012

Boolean expression in SQL

Hello,
In VB/VB.NET, I can use an expression as such to evaluate true/false:
Dim blnValue As Boolean = (SomeObject.Property = "Some value")
Can I do this in T-SQL?
declare @.var bit
set @.var = ?
Thanks.

T-SQL uses ANSI SQL CASE statement for Boolean expression, try the links below for more info. Hope this helps.
http://builder.com.com/5100-6388-5078041.html

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_5t9v.asp

|||

bmains wrote:

Hello,
In VB/VB.NET, I can use an expression as such to evaluate true/false:
Dim blnValue As Boolean = (SomeObject.Property = "Some value")
Can I do this in T-SQL?
declare @.var bit
set @.var = ?
Thanks.


Bit type data can hold either a 1 or 0. So you have to set it to either 1 or 0. You might use it like boolean. One bit value will occupy 1 bytes of space.
Hope this helps.sql

Boolean data type

Is there a boolean data type in SQL? I'm trying to bind a number of check
boxes and radio buttons in a .net app to some columns in a SQL table and I
don't see any boolean data type. What should I do if I want to assign a data
type "boolean" to a table's column in SQL?
--
TSThere is not... Many developers use CHAR(1), with a check constraint
restricting the values to 'Y' or 'N'. Some people like to use BIT instead,
but I personally prefer the former approach...
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"TS" <TS@.discussions.microsoft.com> wrote in message
news:205D2093-75E3-49A5-B2EE-267113AF7ADB@.microsoft.com...
> Is there a boolean data type in SQL? I'm trying to bind a number of check
> boxes and radio buttons in a .net app to some columns in a SQL table and I
> don't see any boolean data type. What should I do if I want to assign a
> data
> type "boolean" to a table's column in SQL?
> --
> TS|||> Is there a boolean data type in SQL?
No, you probably want BIT, though it can take 0, 1, or false. Many people
use CHAR(1) and set a constraint to be either T/F or Y/N.
A|||Well, there is the BIT type. You could also just use a numeric field (of
some sort) and treat it as 0=FALSE, !0=TRUE.
I _think_ bit is preferable, because being a bit, it is either 0 or 1
(or -1, im not sure) and is therefore a logical boolean, but a plain numeric
is more portable if that is a concern.
HTH.
"TS" <TS@.discussions.microsoft.com> wrote in message
news:205D2093-75E3-49A5-B2EE-267113AF7ADB@.microsoft.com...
> Is there a boolean data type in SQL? I'm trying to bind a number of check
> boxes and radio buttons in a .net app to some columns in a SQL table and I
> don't see any boolean data type. What should I do if I want to assign a
> data
> type "boolean" to a table's column in SQL?
> --
> TS|||> No, you probably want BIT, though it can take 0, 1, or false.
Of course, I meant 0, 1, or NULL.|||Uh, oh. Now you're starting to think like SSMS :)
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u$vi6Yt7FHA.2608@.TK2MSFTNGP10.phx.gbl...
> Of course, I meant 0, 1, or NULL.
>|||> Uh, oh. Now you're starting to think like SSMS :)
Nah, I would have put NULL in italics and spelled out 0 as "false" and 1 as
"true"... :-)|||There isn't a boolean type in SQL but you can use bit type.
If you want to assign a data type "boolean" to table column ( I assume that
column's name is Male), you can do
if chkMale.Checked =true then
insert into ... (PersonID, Name, Male) values ('P001','Richard',1)
else
insert into ... (PersonID, Name, Male) values ('P001','Richard',0)
end if
That's it.
"TS" wrote:

> Is there a boolean data type in SQL? I'm trying to bind a number of check
> boxes and radio buttons in a .net app to some columns in a SQL table and I
> don't see any boolean data type. What should I do if I want to assign a da
ta
> type "boolean" to a table's column in SQL?
> --
> TS

Books, articles on printing reports

I am a developer. I current have the Developer Edition of SQL Server 2000 on
my desktop and I am installing VB.Net 2003 and Reporting Services so that a
report, that uses data from a SQL Server 2000 database, can be printed.
I seek the minimal education available that will enable me to design this
report that my customers, who using the database, will print. Are there
suggestions for books or articles that meet this need?
Thanks.
JimMicrosoft SQL Server 2000 Reporting Services is pretty straight forward if
you avoid the filler about how the engine works (actually to be fair all the
books I've seen spend a lot of time on this), there is a better book but its
quite a bit more techy - hitch hikers guide to reporting services.
Phil
"James_101" <James101@.discussions.microsoft.com> wrote in message
news:F730DE37-5437-4E9C-BB8B-BA7776BDEBC9@.microsoft.com...
>I am a developer. I current have the Developer Edition of SQL Server 2000
>on
> my desktop and I am installing VB.Net 2003 and Reporting Services so that
> a
> report, that uses data from a SQL Server 2000 database, can be printed.
> I seek the minimal education available that will enable me to design this
> report that my customers, who using the database, will print. Are there
> suggestions for books or articles that meet this need?
> Thanks.
> Jim|||'Hitchhiker's Guide to SQL Server 2000 Reporting Services' is a very good
book on the subject ...
http://www.sqlreportingservices.net/
There are lot's of on-line resources here ...
http://msdn.microsoft.com/sql/2000/learn/bi/reporting/default.aspx
--
Brendan Reynolds
"James_101" <James101@.discussions.microsoft.com> wrote in message
news:F730DE37-5437-4E9C-BB8B-BA7776BDEBC9@.microsoft.com...
>I am a developer. I current have the Developer Edition of SQL Server 2000
>on
> my desktop and I am installing VB.Net 2003 and Reporting Services so that
> a
> report, that uses data from a SQL Server 2000 database, can be printed.
> I seek the minimal education available that will enable me to design this
> report that my customers, who using the database, will print. Are there
> suggestions for books or articles that meet this need?
> Thanks.
> Jim|||Best book I've read on RS is "CodeFez Guide to Reporting Services". They
released a PDF version a few weeks ago, PDF version is about $20. I found
it a lot easier to read than the others.
http://www.falafel.com/Products/tabid/58/CatalogItemID/19/CatalogID/1/psnavcmd/CatalogItemDetails/Default.aspx
--
Floyd
"James_101" <James101@.discussions.microsoft.com> wrote in message
news:F730DE37-5437-4E9C-BB8B-BA7776BDEBC9@.microsoft.com...
>I am a developer. I current have the Developer Edition of SQL Server 2000
>on
> my desktop and I am installing VB.Net 2003 and Reporting Services so that
> a
> report, that uses data from a SQL Server 2000 database, can be printed.
> I seek the minimal education available that will enable me to design this
> report that my customers, who using the database, will print. Are there
> suggestions for books or articles that meet this need?
> Thanks.
> Jim

Thursday, March 8, 2012

Blocking access to a database after hours running a application

I have a problem: Access to a database on SQL2000 is blocking after many hours running a application developt with vb.net 2003, after a time this blocking is gone and there is a normal acces to this database.
The application is used for logging parameters, counters and other for a part of a factory and is also used for controlling machines. If there is a blocking then there is no possibility control this machines adequate.
The connection-string: SQL_CONNECTION_STRING = "Initial Catalog=PTSBA02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;"
The vb module i use:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Module SQL
Public SQL_CONNECTION_STRING As String
'Structuur van de resultaat array
'Aantal velden is resultaat(0).aantalvelden -> integer
'Aantal records is resultaat(0).aantalrecords -> integer
'De veldnamen zijn resultaat(0).veldnamen(0..aantalvelden) -> string
'De veldinhoud is resultaat(1..aantalrecords).veldinhoud(0..aantalve lden) -> object
Structure Resultaat_
Dim AantalVelden As Integer ' aantal velden in de recordset
Dim AantalRecords As Integer ' aantal records in de recordset
Dim VeldNamen() As String ' namen van de velden
Dim VeldInhoud() As Object ' inhoud van de velden
End Structure
' Resultaat array is de inhoud van de query uitvoering
Public Resultaat() As Resultaat_
Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As Boolean = False) As Boolean
If upd_Q = True Then
GeenResultaat(strSQL)
End If
If upd_Q = False Then
WelResultaat(strSQL)
End If
End Function
Private Sub GeenResultaat(ByVal queryStr As String)
Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING)
myConnection1.Open()
Dim myCommand As SqlCommand = myConnection1.CreateCommand()
Dim myTrans As SqlTransaction
' Start a local transaction
myTrans = myConnection1.BeginTransaction()
' Must assign both transaction object and connection
' to Command object for a pending local transaction
myCommand.Connection = myConnection1
myCommand.Transaction = myTrans
myCommand.CommandTimeout = 1
Try
myCommand.CommandText = queryStr
myCommand.ExecuteNonQuery()
myTrans.Commit()
Catch e As Exception
Try
myTrans.Rollback()
Catch ex As SqlException
If Not myTrans.Connection Is Nothing Then
Debug.WriteLine("An exception of type " & ex.GetType().ToString() & _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while inserting the data. " & Now())
Debug.WriteLine("Neither record was written to database.")
Finally
y = y + 1
myCommand.Dispose()
myConnection1.Close()
myConnection1 = Nothing
End Try
End Sub
Private Sub WelResultaat(ByVal queryStr As String)
Dim lRow As Integer = 0 ' recordnummer
Dim lFIELD As Integer = 0 ' kolomnummer
Dim lRecordsAffected As Integer = 0 ' aantal records
Dim LFieldsAffected As Integer = 0 ' aantal velden
Dim myDataR As SqlDataReader
Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING)
myConnection2.Open()
Dim myCommand As SqlCommand = myConnection2.CreateCommand()
myCommand.Connection = myConnection2
Try
myCommand.CommandText = queryStr
myCommand.CommandTimeout = 2
myDataR = myCommand.ExecuteReader()
'haal het aantal velden op van de recordset
LFieldsAffected = myDataR.FieldCount
'redimensioneer de dynamische array
ReDim Resultaat(1)
ReDim Resultaat(0).VeldNamen(LFieldsAffected)
ReDim Resultaat(0).VeldInhoud(LFieldsAffected)
'zet het aantal velden in resultaat(0).aantalvelden
Resultaat(0).AantalVelden = LFieldsAffected
'Vul de veldnamen in
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
Next
'Vul de inhoud van de query uitkomst in
If myDataR.HasRows() Then
While myDataR.Read
lRow = lRow + 1
ReDim Preserve Resultaat(lRow + 1)
ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
'Vul de velden in
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
Next
End While
End If
'Vul het aantal records in
Resultaat(0).AantalRecords = lRow
Catch e As Exception
Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while reading the data. " & Now())
Debug.WriteLine("Neither record was read from the database.")
Finally
z = z + 1
myCommand.Dispose()
myDataR.Close()
myConnection2.Close()
myConnection2 = Nothing
End Try
End Sub
End Module
a insert query i use:
SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing, commentaar, begin_, einde_, monteur)" & _
" VALUES (" & MM02_Inv_Stor & ", 'MM02', 'JAM op baan', 'einde storing', '--', '" & Format(Now(), "dd-MM-yyyy HH:mm:ss") & "', '--')", True)
a update query i use:
SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" & Mm00_Error_Bits & " where NomItem='" & "lezen02" , True)
and finally a select query:
SQL.ExeQuery("SELECT * FROM mm_telling", False)
every 5 seconds i write abouth 120 update and insert queries and abouth 150 select queries.
the most tables in this database are a few rows (abouth 10 to 20)
The server is MSSQL 2000 with SP 3a
I hope there is a solution for this problem
Martin IJzerman
Martin
A certain amount of blocking is normal and unavoidable.
Do you have long-running queries?
Do you cancel the query but not rolling them back?
"MartinY" <m_ijzerman@.hotmail.com> wrote in message
news:F4A1B423-A225-42C3-A02D-858791A503AD@.microsoft.com...
> I have a problem: Access to a database on SQL2000 is blocking after many
hours running a application developt with vb.net 2003, after a time this
blocking is gone and there is a normal acces to this database.
> The application is used for logging parameters, counters and other for a
part of a factory and is also used for controlling machines. If there is a
blocking then there is no possibility control this machines adequate.
> The connection-string: SQL_CONNECTION_STRING = "Initial
Catalog=PTSBA02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;"
> The vb module i use:
> Imports System
> Imports System.Data
> Imports System.Data.SqlClient
> Module SQL
> Public SQL_CONNECTION_STRING As String
> 'Structuur van de resultaat array
> 'Aantal velden is
-> integer
> 'Aantal records is
-> integer
> 'De veldnamen zijn
ldnamen(0..aantalvelden) -> string
> 'De veldinhoud is
resultaat(1..aantalrecords).veldinhoud(0..aantalve lden) -> object
> Structure Resultaat_
> Dim AantalVelden As Integer ' aantal velden in de recordset
> Dim AantalRecords As Integer ' aantal records in de recordset
> Dim VeldNamen() As String ' namen van de velden
> Dim VeldInhoud() As Object ' inhoud van de velden
> End Structure
> ' Resultaat array is de inhoud van de query uitvoering
> Public Resultaat() As Resultaat_
>
> Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As
Boolean = False) As Boolean
> If upd_Q = True Then
> GeenResultaat(strSQL)
> End If
> If upd_Q = False Then
> WelResultaat(strSQL)
> End If
> End Function
> Private Sub GeenResultaat(ByVal queryStr As String)
> Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection1.Open()
> Dim myCommand As SqlCommand = myConnection1.CreateCommand()
> Dim myTrans As SqlTransaction
> ' Start a local transaction
> myTrans = myConnection1.BeginTransaction()
> ' Must assign both transaction object and connection
> ' to Command object for a pending local transaction
> myCommand.Connection = myConnection1
> myCommand.Transaction = myTrans
> myCommand.CommandTimeout = 1
> Try
> myCommand.CommandText = queryStr
> myCommand.ExecuteNonQuery()
> myTrans.Commit()
> Catch e As Exception
> Try
> myTrans.Rollback()
> Catch ex As SqlException
> If Not myTrans.Connection Is Nothing Then
> Debug.WriteLine("An exception of type " &
ex.GetType().ToString() & _
> " was encountered while attempting to roll
back the transaction.")
> End If
> End Try
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while inserting the data. " &
Now())
> Debug.WriteLine("Neither record was written to database.")
> Finally
> y = y + 1
> myCommand.Dispose()
> myConnection1.Close()
> myConnection1 = Nothing
> End Try
> End Sub
> Private Sub WelResultaat(ByVal queryStr As String)
> Dim lRow As Integer = 0 ' recordnummer
> Dim lFIELD As Integer = 0 ' kolomnummer
> Dim lRecordsAffected As Integer = 0 ' aantal records
> Dim LFieldsAffected As Integer = 0 ' aantal velden
> Dim myDataR As SqlDataReader
> Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection2.Open()
> Dim myCommand As SqlCommand = myConnection2.CreateCommand()
> myCommand.Connection = myConnection2
> Try
> myCommand.CommandText = queryStr
> myCommand.CommandTimeout = 2
> myDataR = myCommand.ExecuteReader()
> 'haal het aantal velden op van de recordset
> LFieldsAffected = myDataR.FieldCount
> 'redimensioneer de dynamische array
> ReDim Resultaat(1)
> ReDim Resultaat(0).VeldNamen(LFieldsAffected)
> ReDim Resultaat(0).VeldInhoud(LFieldsAffected)
> 'zet het aantal velden in resultaat(0).aantalvelden
> Resultaat(0).AantalVelden = LFieldsAffected
> 'Vul de veldnamen in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
> Next
> 'Vul de inhoud van de query uitkomst in
> If myDataR.HasRows() Then
> While myDataR.Read
> lRow = lRow + 1
> ReDim Preserve Resultaat(lRow + 1)
> ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
> 'Vul de velden in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
> Next
> End While
> End If
> 'Vul het aantal records in
> Resultaat(0).AantalRecords = lRow
> Catch e As Exception
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while reading the data. " & Now())
> Debug.WriteLine("Neither record was read from the database.")
> Finally
> z = z + 1
> myCommand.Dispose()
> myDataR.Close()
> myConnection2.Close()
> myConnection2 = Nothing
> End Try
> End Sub
> End Module
> a insert query i use:
> SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing,
commentaar, begin_, einde_, monteur)" & _
> " VALUES (" & MM02_Inv_Stor & ",
'MM02', 'JAM op baan', 'einde storing', '--', '" & Format(Now(),
"dd-MM-yyyy HH:mm:ss") & "', '--')", True)
> a update query i use:
> SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" &
Mm00_Error_Bits & " where NomItem='" & "lezen02" , True)
> and finally a select query:
> SQL.ExeQuery("SELECT * FROM mm_telling", False)
> every 5 seconds i write abouth 120 update and insert queries and abouth
150 select queries.
> the most tables in this database are a few rows (abouth 10 to 20)
> The server is MSSQL 2000 with SP 3a
> I hope there is a solution for this problem
> Martin IJzerman
>
>
|||Uri
What do you mean with, 'a certain amount of blocking is normal and unavoidable.', i hope it is not true.
In my application blocking is not acceptable. before i have written a application with MySQL as database-server and after 2.5 years 24 hours 7 days a week, there are never blocking problems. The policy by the factory i work for is using MSSQLserver 2000,
and there is no possibility to change to a other db-server.
I shall try to cancel the query in state of rolling them back.
Thanks, Martin IJzerman
|||Martin
Unfortunatly it is true.
Blocking occurs when one connection to SQL Server locks one or more records,
and a second connection to SQL Server requires a conflicting lock type on
the record or records locked by the first connection. This causes the second
connection to wait until the first connection releases its locks. By
default, a connection will wait an unlimited amount of time for the blocking
lock to go away.
To help identify blocking in your databases, Microsoft has two separate
stored procedures listed on their website (one each for SQL Server 7.0 and
2000) you can use to help identify blocking problems on your SQL Servers. On
these pages are scripts you can use to create stored procedures that you can
run anytime to help you identify blocking issues.
INF: How to Monitor SQL Server 2000 Blocking (Q271509)
"MartinY" <anonymous@.discussions.microsoft.com> wrote in message
news:D24D7BA8-48DC-4FFC-828F-7231E753EC08@.microsoft.com...
> Uri
> What do you mean with, 'a certain amount of blocking is normal and
unavoidable.', i hope it is not true.
> In my application blocking is not acceptable. before i have written a
application with MySQL as database-server and after 2.5 years 24 hours 7
days a week, there are never blocking problems. The policy by the factory i
work for is using MSSQLserver 2000, and there is no possibility to change to
a other db-server.
> I shall try to cancel the query in state of rolling them back.
> Thanks, Martin IJzerman
>
|||Ury,
I have tried 'How to Monitor SQL Server 2000 Blocking (Q271509)' script and in the logging file there is no blocking detected, and also in the profiler trace there are no special things to see. There is after 10 to 14 hours some blocking with is not detec
ted.
Martin IJzerman.

Blocking access to a database after hours running a application

I have a problem: Access to a database on SQL2000 is blocking after many hours running a application developt with vb.net 2003, after a time this blocking is gone and there is a normal acces to this database
The application is used for logging parameters, counters and other for a part of a factory and is also used for controlling machines. If there is a blocking then there is no possibility control this machines adequate
The connection-string: SQL_CONNECTION_STRING = "Initial Catalog=PTSBA02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;
The vb module i use
Imports Syste
Imports System.Dat
Imports System.Data.SqlClien
Module SQ
Public SQL_CONNECTION_STRING As Strin
'Structuur van de resultaat arra
'Aantal velden is resultaat(0).aantalvelden -> intege
'Aantal records is resultaat(0).aantalrecords -> intege
'De veldnamen zijn resultaat(0).veldnamen(0..aantalvelden) -> strin
'De veldinhoud is resultaat(1..aantalrecords).veldinhoud(0..aantalvelden) -> objec
Structure Resultaat
Dim AantalVelden As Integer ' aantal velden in de recordset
Dim AantalRecords As Integer ' aantal records in de recordse
Dim VeldNamen() As String ' namen van de velde
Dim VeldInhoud() As Object ' inhoud van de velde
End Structur
' Resultaat array is de inhoud van de query uitvoerin
Public Resultaat() As Resultaat
Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As Boolean = False) As Boolea
If upd_Q = True The
GeenResultaat(strSQL
End I
If upd_Q = False The
WelResultaat(strSQL
End I
End Functio
Private Sub GeenResultaat(ByVal queryStr As String
Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING
myConnection1.Open(
Dim myCommand As SqlCommand = myConnection1.CreateCommand(
Dim myTrans As SqlTransactio
' Start a local transactio
myTrans = myConnection1.BeginTransaction(
' Must assign both transaction object and connectio
' to Command object for a pending local transactio
myCommand.Connection = myConnection
myCommand.Transaction = myTran
myCommand.CommandTimeout = Tr
myCommand.CommandText = querySt
myCommand.ExecuteNonQuery(
myTrans.Commit(
Catch e As Exceptio
Tr
myTrans.Rollback(
Catch ex As SqlExceptio
If Not myTrans.Connection Is Nothing The
Debug.WriteLine("An exception of type " & ex.GetType().ToString() &
" was encountered while attempting to roll back the transaction."
End I
End Tr
Debug.WriteLine("An exception of type " & e.GetType().ToString() &
"was encountered while inserting the data. " & Now()
Debug.WriteLine("Neither record was written to database."
Finall
y = y +
myCommand.Dispose(
myConnection1.Close(
myConnection1 = Nothin
End Tr
End Su
Private Sub WelResultaat(ByVal queryStr As String
Dim lRow As Integer = 0 ' recordnumme
Dim lFIELD As Integer = 0 ' kolomnumme
Dim lRecordsAffected As Integer = 0 ' aantal records
Dim LFieldsAffected As Integer = 0 ' aantal velde
Dim myDataR As SqlDataReade
Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING
myConnection2.Open(
Dim myCommand As SqlCommand = myConnection2.CreateCommand(
myCommand.Connection = myConnection
Tr
myCommand.CommandText = querySt
myCommand.CommandTimeout = myDataR = myCommand.ExecuteReader(
'haal het aantal velden op van de recordse
LFieldsAffected = myDataR.FieldCoun
'redimensioneer de dynamische arra
ReDim Resultaat(1
ReDim Resultaat(0).VeldNamen(LFieldsAffected
ReDim Resultaat(0).VeldInhoud(LFieldsAffected
'zet het aantal velden in resultaat(0).aantalvelde
Resultaat(0).AantalVelden = LFieldsAffecte
'Vul de veldnamen i
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
Next
'Vul de inhoud van de query uitkomst in
If myDataR.HasRows() Then
While myDataR.Read
lRow = lRow + 1
ReDim Preserve Resultaat(lRow + 1)
ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
'Vul de velden in
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
Next
End While
End If
'Vul het aantal records in
Resultaat(0).AantalRecords = lRow
Catch e As Exception
Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while reading the data. " & Now())
Debug.WriteLine("Neither record was read from the database.")
Finally
z = z + 1
myCommand.Dispose()
myDataR.Close()
myConnection2.Close()
myConnection2 = Nothing
End Try
End Sub
End Module
a insert query i use:
SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing, commentaar, begin_, einde_, monteur)" & _
" VALUES (" & MM02_Inv_Stor & ", 'MM02', 'JAM op baan', 'einde storing', '--', '" & Format(Now(), "dd-MM-yyyy HH:mm:ss") & "', '--')", True)
a update query i use:
SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" & Mm00_Error_Bits & " where NomItem='" & "lezen02" , True)
and finally a select query:
SQL.ExeQuery("SELECT * FROM mm_telling", False)
every 5 seconds i write abouth 120 update and insert queries and abouth 150 select queries.
the most tables in this database are a few rows (abouth 10 to 20)
The server is MSSQL 2000 with SP 3a
I hope there is a solution for this problem
Martin IJzermanMartin
A certain amount of blocking is normal and unavoidable.
Do you have long-running queries?
Do you cancel the query but not rolling them back?
"MartinY" <m_ijzerman@.hotmail.com> wrote in message
news:F4A1B423-A225-42C3-A02D-858791A503AD@.microsoft.com...
> I have a problem: Access to a database on SQL2000 is blocking after many
hours running a application developt with vb.net 2003, after a time this
blocking is gone and there is a normal acces to this database.
> The application is used for logging parameters, counters and other for a
part of a factory and is also used for controlling machines. If there is a
blocking then there is no possibility control this machines adequate.
> The connection-string: SQL_CONNECTION_STRING = "Initial
Catalog=PTSBA02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;"
> The vb module i use:
> Imports System
> Imports System.Data
> Imports System.Data.SqlClient
> Module SQL
> Public SQL_CONNECTION_STRING As String
> 'Structuur van de resultaat array
> 'Aantal velden is
-> integer
> 'Aantal records is
-> integer
> 'De veldnamen zijn
ldnamen(0..aantalvelden) -> string
> 'De veldinhoud is
resultaat(1..aantalrecords).veldinhoud(0..aantalvelden) -> object
> Structure Resultaat_
> Dim AantalVelden As Integer ' aantal velden in de recordset
> Dim AantalRecords As Integer ' aantal records in de recordset
> Dim VeldNamen() As String ' namen van de velden
> Dim VeldInhoud() As Object ' inhoud van de velden
> End Structure
> ' Resultaat array is de inhoud van de query uitvoering
> Public Resultaat() As Resultaat_
>
> Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As
Boolean = False) As Boolean
> If upd_Q = True Then
> GeenResultaat(strSQL)
> End If
> If upd_Q = False Then
> WelResultaat(strSQL)
> End If
> End Function
> Private Sub GeenResultaat(ByVal queryStr As String)
> Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection1.Open()
> Dim myCommand As SqlCommand = myConnection1.CreateCommand()
> Dim myTrans As SqlTransaction
> ' Start a local transaction
> myTrans = myConnection1.BeginTransaction()
> ' Must assign both transaction object and connection
> ' to Command object for a pending local transaction
> myCommand.Connection = myConnection1
> myCommand.Transaction = myTrans
> myCommand.CommandTimeout = 1
> Try
> myCommand.CommandText = queryStr
> myCommand.ExecuteNonQuery()
> myTrans.Commit()
> Catch e As Exception
> Try
> myTrans.Rollback()
> Catch ex As SqlException
> If Not myTrans.Connection Is Nothing Then
> Debug.WriteLine("An exception of type " &
ex.GetType().ToString() & _
> " was encountered while attempting to roll
back the transaction.")
> End If
> End Try
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while inserting the data. " &
Now())
> Debug.WriteLine("Neither record was written to database.")
> Finally
> y = y + 1
> myCommand.Dispose()
> myConnection1.Close()
> myConnection1 = Nothing
> End Try
> End Sub
> Private Sub WelResultaat(ByVal queryStr As String)
> Dim lRow As Integer = 0 ' recordnummer
> Dim lFIELD As Integer = 0 ' kolomnummer
> Dim lRecordsAffected As Integer = 0 ' aantal records
> Dim LFieldsAffected As Integer = 0 ' aantal velden
> Dim myDataR As SqlDataReader
> Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection2.Open()
> Dim myCommand As SqlCommand = myConnection2.CreateCommand()
> myCommand.Connection = myConnection2
> Try
> myCommand.CommandText = queryStr
> myCommand.CommandTimeout = 2
> myDataR = myCommand.ExecuteReader()
> 'haal het aantal velden op van de recordset
> LFieldsAffected = myDataR.FieldCount
> 'redimensioneer de dynamische array
> ReDim Resultaat(1)
> ReDim Resultaat(0).VeldNamen(LFieldsAffected)
> ReDim Resultaat(0).VeldInhoud(LFieldsAffected)
> 'zet het aantal velden in resultaat(0).aantalvelden
> Resultaat(0).AantalVelden = LFieldsAffected
> 'Vul de veldnamen in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
> Next
> 'Vul de inhoud van de query uitkomst in
> If myDataR.HasRows() Then
> While myDataR.Read
> lRow = lRow + 1
> ReDim Preserve Resultaat(lRow + 1)
> ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
> 'Vul de velden in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
> Next
> End While
> End If
> 'Vul het aantal records in
> Resultaat(0).AantalRecords = lRow
> Catch e As Exception
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while reading the data. " & Now())
> Debug.WriteLine("Neither record was read from the database.")
> Finally
> z = z + 1
> myCommand.Dispose()
> myDataR.Close()
> myConnection2.Close()
> myConnection2 = Nothing
> End Try
> End Sub
> End Module
> a insert query i use:
> SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing,
commentaar, begin_, einde_, monteur)" & _
> " VALUES (" & MM02_Inv_Stor & ",
'MM02', 'JAM op baan', 'einde storing', '--', '" & Format(Now(),
"dd-MM-yyyy HH:mm:ss") & "', '--')", True)
> a update query i use:
> SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" &
Mm00_Error_Bits & " where NomItem='" & "lezen02" , True)
> and finally a select query:
> SQL.ExeQuery("SELECT * FROM mm_telling", False)
> every 5 seconds i write abouth 120 update and insert queries and abouth
150 select queries.
> the most tables in this database are a few rows (abouth 10 to 20)
> The server is MSSQL 2000 with SP 3a
> I hope there is a solution for this problem
> Martin IJzerman
>
>|||Ur
What do you mean with, 'a certain amount of blocking is normal and unavoidable.', i hope it is not true
In my application blocking is not acceptable. before i have written a application with MySQL as database-server and after 2.5 years 24 hours 7 days a week, there are never blocking problems. The policy by the factory i work for is using MSSQLserver 2000, and there is no possibility to change to a other db-server
I shall try to cancel the query in state of rolling them back
Thanks, Martin IJzerma|||Martin
Unfortunatly it is true.
Blocking occurs when one connection to SQL Server locks one or more records,
and a second connection to SQL Server requires a conflicting lock type on
the record or records locked by the first connection. This causes the second
connection to wait until the first connection releases its locks. By
default, a connection will wait an unlimited amount of time for the blocking
lock to go away.
To help identify blocking in your databases, Microsoft has two separate
stored procedures listed on their website (one each for SQL Server 7.0 and
2000) you can use to help identify blocking problems on your SQL Servers. On
these pages are scripts you can use to create stored procedures that you can
run anytime to help you identify blocking issues.
INF: How to Monitor SQL Server 2000 Blocking (Q271509)
"MartinY" <anonymous@.discussions.microsoft.com> wrote in message
news:D24D7BA8-48DC-4FFC-828F-7231E753EC08@.microsoft.com...
> Uri
> What do you mean with, 'a certain amount of blocking is normal and
unavoidable.', i hope it is not true.
> In my application blocking is not acceptable. before i have written a
application with MySQL as database-server and after 2.5 years 24 hours 7
days a week, there are never blocking problems. The policy by the factory i
work for is using MSSQLserver 2000, and there is no possibility to change to
a other db-server.
> I shall try to cancel the query in state of rolling them back.
> Thanks, Martin IJzerman
>|||Ury
I have tried 'How to Monitor SQL Server 2000 Blocking (Q271509)' script and in the logging file there is no blocking detected, and also in the profiler trace there are no special things to see. There is after 10 to 14 hours some blocking with is not detected
Martin IJzerman

Blocking access to a database after hours running a application

I have a problem: Access to a database on SQL2000 is blocking after many hou
rs running a application developt with vb.net 2003, after a time this blocki
ng is gone and there is a normal acces to this database.
The application is used for logging parameters, counters and other for a par
t of a factory and is also used for controlling machines. If there is a bloc
king then there is no possibility control this machines adequate.
The connection-string: SQL_CONNECTION_STRING = "Initial Catalog=PTSB
A02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;"
The vb module i use:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Module SQL
Public SQL_CONNECTION_STRING As String
'Structuur van de resultaat array
'Aantal velden is resultaat(0).aantalvelden ->
integer
'Aantal records is resultaat(0).aantalrecords ->
integer
'De veldnamen zijn resultaat(0).veldnamen(0..aantalvelden) ->
string
'De veldinhoud is resultaat(1..aantalrecords).veldinhoud(0..aantalvelden) ->
object
Structure Resultaat_
Dim AantalVelden As Integer ' aantal velden in de recordset
Dim AantalRecords As Integer ' aantal records in de recordset
Dim VeldNamen() As String ' namen van de velden
Dim VeldInhoud() As Object ' inhoud van de velden
End Structure
' Resultaat array is de inhoud van de query uitvoering
Public Resultaat() As Resultaat_
Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As Boo
lean = False) As Boolean
If upd_Q = True Then
GeenResultaat(strSQL)
End If
If upd_Q = False Then
WelResultaat(strSQL)
End If
End Function
Private Sub GeenResultaat(ByVal queryStr As String)
Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING)
myConnection1.Open()
Dim myCommand As SqlCommand = myConnection1.CreateCommand()
Dim myTrans As SqlTransaction
' Start a local transaction
myTrans = myConnection1.BeginTransaction()
' Must assign both transaction object and connection
' to Command object for a pending local transaction
myCommand.Connection = myConnection1
myCommand.Transaction = myTrans
myCommand.CommandTimeout = 1
Try
myCommand.CommandText = queryStr
myCommand.ExecuteNonQuery()
myTrans.Commit()
Catch e As Exception
Try
myTrans.Rollback()
Catch ex As SqlException
If Not myTrans.Connection Is Nothing Then
Debug.WriteLine("An exception of type " & ex.GetType().ToString() & _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while inserting the data. " & Now())
Debug.WriteLine("Neither record was written to database.")
Finally
y = y + 1
myCommand.Dispose()
myConnection1.Close()
myConnection1 = Nothing
End Try
End Sub
Private Sub WelResultaat(ByVal queryStr As String)
Dim lRow As Integer = 0 ' recordnummer
Dim lFIELD As Integer = 0 ' kolomnummer
Dim lRecordsAffected As Integer = 0 ' aantal records
Dim LFieldsAffected As Integer = 0 ' aantal velden
Dim myDataR As SqlDataReader
Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING)
myConnection2.Open()
Dim myCommand As SqlCommand = myConnection2.CreateCommand()
myCommand.Connection = myConnection2
Try
myCommand.CommandText = queryStr
myCommand.CommandTimeout = 2
myDataR = myCommand.ExecuteReader()
'haal het aantal velden op van de recordset
LFieldsAffected = myDataR.FieldCount
'redimensioneer de dynamische array
ReDim Resultaat(1)
ReDim Resultaat(0).VeldNamen(LFieldsAffected)
ReDim Resultaat(0).VeldInhoud(LFieldsAffected)
'zet het aantal velden in resultaat(0).aantalvelden
Resultaat(0).AantalVelden = LFieldsAffected
'Vul de veldnamen in
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
Next
'Vul de inhoud van de query uitkomst in
If myDataR.HasRows() Then
While myDataR.Read
lRow = lRow + 1
ReDim Preserve Resultaat(lRow + 1)
ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
'Vul de velden in
For lFIELD = 0 To LFieldsAffected - 1
Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
Next
End While
End If
'Vul het aantal records in
Resultaat(0).AantalRecords = lRow
Catch e As Exception
Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while reading the data. " & Now())
Debug.WriteLine("Neither record was read from the database.")
Finally
z = z + 1
myCommand.Dispose()
myDataR.Close()
myConnection2.Close()
myConnection2 = Nothing
End Try
End Sub
End Module
a insert query i use:
SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing, commentaar,
begin_, einde_, monteur)" & _
" VALUES (" & MM02_Inv_Stor & ", 'MM02', 'JAM op baan', 'einde storing', '--
--', '" & Format(Now(), "dd-MM-yyyy HH:mm:ss") & "', '--')", True)
a update query i use:
SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" & Mm00_Error_Bi
ts & " where NomItem='" & "lezen02" , True)
and finally a select query:
SQL.ExeQuery("SELECT * FROM mm_telling", False)
every 5 seconds i write abouth 120 update and insert queries and abouth 150
select queries.
the most tables in this database are a few rows (abouth 10 to 20)
The server is MSSQL 2000 with SP 3a
I hope there is a solution for this problem
Martin IJzermanMartin
A certain amount of blocking is normal and unavoidable.
Do you have long-running queries?
Do you cancel the query but not rolling them back?
"MartinY" <m_ijzerman@.hotmail.com> wrote in message
news:F4A1B423-A225-42C3-A02D-858791A503AD@.microsoft.com...
> I have a problem: Access to a database on SQL2000 is blocking after many
hours running a application developt with vb.net 2003, after a time this
blocking is gone and there is a normal acces to this database.
> The application is used for logging parameters, counters and other for a
part of a factory and is also used for controlling machines. If there is a
blocking then there is no possibility control this machines adequate.
> The connection-string: SQL_CONNECTION_STRING = "Initial
Catalog=PTSBA02;Data Source=NLENSAPP01\PDE;Integrated Security=SSPI;"
> The vb module i use:
> Imports System
> Imports System.Data
> Imports System.Data.SqlClient
> Module SQL
> Public SQL_CONNECTION_STRING As String
> 'Structuur van de resultaat array
> 'Aantal velden is
-> integer
> 'Aantal records is
-> integer
> 'De veldnamen zijn
ldnamen(0..aantalvelden) -> string
> 'De veldinhoud is
resultaat(1..aantalrecords).veldinhoud(0..aantalvelden) -> object
> Structure Resultaat_
> Dim AantalVelden As Integer ' aantal velden in de recordset
> Dim AantalRecords As Integer ' aantal records in de recordset
> Dim VeldNamen() As String ' namen van de velden
> Dim VeldInhoud() As Object ' inhoud van de velden
> End Structure
> ' Resultaat array is de inhoud van de query uitvoering
> Public Resultaat() As Resultaat_
>
> Public Function ExeQuery(ByVal strSQL As String, Optional ByVal upd_Q As
Boolean = False) As Boolean
> If upd_Q = True Then
> GeenResultaat(strSQL)
> End If
> If upd_Q = False Then
> WelResultaat(strSQL)
> End If
> End Function
> Private Sub GeenResultaat(ByVal queryStr As String)
> Dim myConnection1 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection1.Open()
> Dim myCommand As SqlCommand = myConnection1.CreateCommand()
> Dim myTrans As SqlTransaction
> ' Start a local transaction
> myTrans = myConnection1.BeginTransaction()
> ' Must assign both transaction object and connection
> ' to Command object for a pending local transaction
> myCommand.Connection = myConnection1
> myCommand.Transaction = myTrans
> myCommand.CommandTimeout = 1
> Try
> myCommand.CommandText = queryStr
> myCommand.ExecuteNonQuery()
> myTrans.Commit()
> Catch e As Exception
> Try
> myTrans.Rollback()
> Catch ex As SqlException
> If Not myTrans.Connection Is Nothing Then
> Debug.WriteLine("An exception of type " &
ex.GetType().ToString() & _
> " was encountered while attempting to roll
back the transaction.")
> End If
> End Try
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while inserting the data. " &
Now())
> Debug.WriteLine("Neither record was written to database.")
> Finally
> y = y + 1
> myCommand.Dispose()
> myConnection1.Close()
> myConnection1 = Nothing
> End Try
> End Sub
> Private Sub WelResultaat(ByVal queryStr As String)
> Dim lRow As Integer = 0 ' recordnummer
> Dim lFIELD As Integer = 0 ' kolomnummer
> Dim lRecordsAffected As Integer = 0 ' aantal records
> Dim LFieldsAffected As Integer = 0 ' aantal velden
> Dim myDataR As SqlDataReader
> Dim myConnection2 As New SqlConnection(SQL_CONNECTION_STRING)
> myConnection2.Open()
> Dim myCommand As SqlCommand = myConnection2.CreateCommand()
> myCommand.Connection = myConnection2
> Try
> myCommand.CommandText = queryStr
> myCommand.CommandTimeout = 2
> myDataR = myCommand.ExecuteReader()
> 'haal het aantal velden op van de recordset
> LFieldsAffected = myDataR.FieldCount
> 'redimensioneer de dynamische array
> ReDim Resultaat(1)
> ReDim Resultaat(0).VeldNamen(LFieldsAffected)
> ReDim Resultaat(0).VeldInhoud(LFieldsAffected)
> 'zet het aantal velden in resultaat(0).aantalvelden
> Resultaat(0).AantalVelden = LFieldsAffected
> 'Vul de veldnamen in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(0).VeldNamen(lFIELD) = myDataR.GetName(lFIELD)
> Next
> 'Vul de inhoud van de query uitkomst in
> If myDataR.HasRows() Then
> While myDataR.Read
> lRow = lRow + 1
> ReDim Preserve Resultaat(lRow + 1)
> ReDim Preserve Resultaat(lRow).VeldInhoud(LFieldsAffected + 1)
> 'Vul de velden in
> For lFIELD = 0 To LFieldsAffected - 1
> Resultaat(lRow).VeldInhoud(lFIELD) = myDataR.GetValue(lFIELD)
> Next
> End While
> End If
> 'Vul het aantal records in
> Resultaat(0).AantalRecords = lRow
> Catch e As Exception
> Debug.WriteLine("An exception of type " & e.GetType().ToString() & _
> "was encountered while reading the data. " & Now())
> Debug.WriteLine("Neither record was read from the database.")
> Finally
> z = z + 1
> myCommand.Dispose()
> myDataR.Close()
> myConnection2.Close()
> myConnection2 = Nothing
> End Try
> End Sub
> End Module
> a insert query i use:
> SQL.ExeQuery("INSERT INTO mm_storing (index_nr, nummer, storing,
commentaar, begin_, einde_, monteur)" & _
> " VALUES (" & MM02_Inv_Stor & ",
'MM02', 'JAM op baan', 'einde storing', '--', '" & Format(Now(),
"dd-MM-yyyy HH:mm:ss") & "', '--')", True)
> a update query i use:
> SQL.ExeQuery("UPDATE MM00 SET waarde" & BlokKeuze_MM00 & "=" &
Mm00_Error_Bits & " where NomItem='" & "lezen02" , True)
> and finally a select query:
> SQL.ExeQuery("SELECT * FROM mm_telling", False)
> every 5 seconds i write abouth 120 update and insert queries and abouth
150 select queries.
> the most tables in this database are a few rows (abouth 10 to 20)
> The server is MSSQL 2000 with SP 3a
> I hope there is a solution for this problem
> Martin IJzerman
>
>|||Uri
What do you mean with, 'a certain amount of blocking is normal and unavoidab
le.', i hope it is not true.
In my application blocking is not acceptable. before i have written a applic
ation with mysql as database-server and after 2.5 years 24 hours 7 days a we
ek, there are never blocking problems. The policy by the factory i work for
is using MSSQLserver 2000,
and there is no possibility to change to a other db-server.
I shall try to cancel the query in state of rolling them back.
Thanks, Martin IJzerman|||Martin
Unfortunatly it is true.
Blocking occurs when one connection to SQL Server locks one or more records,
and a second connection to SQL Server requires a conflicting lock type on
the record or records locked by the first connection. This causes the second
connection to wait until the first connection releases its locks. By
default, a connection will wait an unlimited amount of time for the blocking
lock to go away.
To help identify blocking in your databases, Microsoft has two separate
stored procedures listed on their website (one each for SQL Server 7.0 and
2000) you can use to help identify blocking problems on your SQL Servers. On
these pages are scripts you can use to create stored procedures that you can
run anytime to help you identify blocking issues.
INF: How to Monitor SQL Server 2000 Blocking (Q271509)
"MartinY" <anonymous@.discussions.microsoft.com> wrote in message
news:D24D7BA8-48DC-4FFC-828F-7231E753EC08@.microsoft.com...
> Uri
> What do you mean with, 'a certain amount of blocking is normal and
unavoidable.', i hope it is not true.
> In my application blocking is not acceptable. before i have written a
application with mysql as database-server and after 2.5 years 24 hours 7
days a week, there are never blocking problems. The policy by the factory i
work for is using MSSQLserver 2000, and there is no possibility to change to
a other db-server.
> I shall try to cancel the query in state of rolling them back.
> Thanks, Martin IJzerman
>|||Ury,
I have tried 'How to Monitor SQL Server 2000 Blocking (Q271509)' script and
in the logging file there is no blocking detected, and also in the profiler
trace there are no special things to see. There is after 10 to 14 hours some
blocking with is not detec
ted.
Martin IJzerman.

Friday, February 24, 2012

blank textbox is NOT null ..

This must be a common asp.net / sql server problem.
I only want to filter on the date when the filterdate textbox has a
value. Not sure if this is the best approach, but it does not appear to
be working.. I was hoping blank mean no filtering and all qualifying
rows returning
<asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode =
@.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
datetime))and enddate >= IsNull(cast(@.DateFilter as
datetime),cast('1/1/1999' as datetime)) order by StartDate" >
<asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
PropertyName="Text" Type="Datetime" />Hi
If you are going to dynamically create the SQL statement in you ASP then you
can omit the clause completely if no value is entered. If you are going to
use a stored procedure then check out
http://www.sommarskog.se/dyn-search.html and
http://www.sommarskog.se/dynamic_sql.html
John
"jobs" wrote:

> This must be a common asp.net / sql server problem.
> I only want to filter on the date when the filterdate textbox has a
> value. Not sure if this is the best approach, but it does not appear to
> be working.. I was hoping blank mean no filtering and all qualifying
> rows returning
> <asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
> SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode =
> @.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
> startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
> datetime))and enddate >= IsNull(cast(@.DateFilter as
> datetime),cast('1/1/1999' as datetime)) order by StartDate" >
> <asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
> PropertyName="Text" Type="Datetime" />
>

blank textbox is NOT null ..

This must be a common asp.net / sql server problem.
I only want to filter on the date when the filterdate textbox has a
value. Not sure if this is the best approach, but it does not appear to
be working.. I was hoping blank mean no filtering and all qualifying
rows returning
<asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode =
@.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
datetime))and enddate >= IsNull(cast(@.DateFilter as
datetime),cast('1/1/1999' as datetime)) order by StartDate" >
<asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
PropertyName="Text" Type="Datetime" />
Hi
If you are going to dynamically create the SQL statement in you ASP then you
can omit the clause completely if no value is entered. If you are going to
use a stored procedure then check out
http://www.sommarskog.se/dyn-search.html and
http://www.sommarskog.se/dynamic_sql.html
John
"jobs" wrote:

> This must be a common asp.net / sql server problem.
> I only want to filter on the date when the filterdate textbox has a
> value. Not sure if this is the best approach, but it does not appear to
> be working.. I was hoping blank mean no filtering and all qualifying
> rows returning
> <asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
> SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode =
> @.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
> startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
> datetime))and enddate >= IsNull(cast(@.DateFilter as
> datetime),cast('1/1/1999' as datetime)) order by StartDate" >
> <asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
> PropertyName="Text" Type="Datetime" />
>

blank textbox is NOT null ..

This must be a common asp.net / sql server problem.
I only want to filter on the date when the filterdate textbox has a
value. Not sure if this is the best approach, but it does not appear to
be working.. I was hoping blank mean no filtering and all qualifying
rows returning
<asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode = @.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
datetime))and enddate >= IsNull(cast(@.DateFilter as
datetime),cast('1/1/1999' as datetime)) order by StartDate" >
<asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
PropertyName="Text" Type="Datetime" />Hi
If you are going to dynamically create the SQL statement in you ASP then you
can omit the clause completely if no value is entered. If you are going to
use a stored procedure then check out
http://www.sommarskog.se/dyn-search.html and
http://www.sommarskog.se/dynamic_sql.html
John
"jobs" wrote:
> This must be a common asp.net / sql server problem.
> I only want to filter on the date when the filterdate textbox has a
> value. Not sure if this is the best approach, but it does not appear to
> be working.. I was hoping blank mean no filtering and all qualifying
> rows returning
> <asp:TextBox ID="DateFilter" runat="server"></asp:TextBox>
> SelectCommand="SELECT * FROM [GEN_RouteInfo_vw] WHERE plancode => @.plancode and RouteCode=@.RouteCode and CountryId=@.CountryId and
> startdate <= IsNull(cast(@.DateFilter as datetime),cast('1/1/2999' as
> datetime))and enddate >= IsNull(cast(@.DateFilter as
> datetime),cast('1/1/1999' as datetime)) order by StartDate" >
> <asp:ControlParameter ControlID="DateFilter" Name="DateFilter"
> PropertyName="Text" Type="Datetime" />
>

Sunday, February 19, 2012

Blank Pages in report

I am supporting a web based application (ASP.NET 1.1) that uses RS 2005 on the production server. I needed to change a report, I make my changes, it looks fine in the Developer Viewer and it exports fine to PDF on my PC. I have deployed it to the production server but when you pull the report within the application (PDF format) it has 3 additional blank pages on the end of the report. The report is the correct size. It does not excede the 8/11 page size including the margins, there are no hidden fields. The report does have 4 tables. I have even viewed the report from //localhost/reports on the server and it shows only one page and exports to pdf with one page. I have looked at all the postings that deal with Blank pages and nothing seems to correct the problem.

Does anyone have any ideas?

Thanks

If you take things out does it still put 3 extra pages in?|||I can try that tonight. Since this only happens in production, I must wait to off hours.|||

Ok, I found the issue. This report is just a sub report to a master report. The master report was not formated to fit on 8.5/11 paper. Thus it pushed the additional blank pages. Once I formated the Master report, there where no more blank pages.

Thanks

|||

This is the most common problem for blank pages in a report.

In development the user will accidentally extend the width of the report beyond normal page limits, so extra pages get printed.

Blank Pages in a report <-- text put there for people searching on this problem.

Make sure that your main report page setup is correct for the hieght and width of your report, and also double check any subreports.

Daryl

Blank Pages in report

I am supporting a web based application (ASP.NET 1.1) that uses RS 2005 on the production server. I needed to change a report, I make my changes, it looks fine in the Developer Viewer and it exports fine to PDF on my PC. I have deployed it to the production server but when you pull the report within the application (PDF format) it has 3 additional blank pages on the end of the report. The report is the correct size. It does not excede the 8/11 page size including the margins, there are no hidden fields. The report does have 4 tables. I have even viewed the report from //localhost/reports on the server and it shows only one page and exports to pdf with one page. I have looked at all the postings that deal with Blank pages and nothing seems to correct the problem.

Does anyone have any ideas?

Thanks

If you take things out does it still put 3 extra pages in?
|||I can try that tonight. Since this only happens in production, I must wait to off hours.|||

Ok, I found the issue. This report is just a sub report to a master report. The master report was not formated to fit on 8.5/11 paper. Thus it pushed the additional blank pages. Once I formated the Master report, there where no more blank pages.

Thanks

|||

This is the most common problem for blank pages in a report.

In development the user will accidentally extend the width of the report beyond normal page limits, so extra pages get printed.

Blank Pages in a report <-- text put there for people searching on this problem.

Make sure that your main report page setup is correct for the hieght and width of your report, and also double check any subreports.

Daryl

Friday, February 10, 2012

BitArray to binary

I want to store a binary string in SqlServer from VB .NET through a
stored procedure. I have been storing the binary data in a BitArray
which I am not set on by any means. When I pass the BitArray into a
stored procedure, which is looking for a variable of type binary, it
throws the following: "Object must implement IConvertible." BitArray
obviously does not implement IConvertable.

If anyone has a good way of passing binary data into a stored
procedure through a parameter array I'd appreciate it."Ramzi Abboud" <ramziabb@.gmail.com> wrote in message
news:a5617e65.0410141217.21e48d0@.posting.google.co m...
>I want to store a binary string in SqlServer from VB .NET through a
> stored procedure. I have been storing the binary data in a BitArray
> which I am not set on by any means. When I pass the BitArray into a
> stored procedure, which is looking for a variable of type binary, it
> throws the following: "Object must implement IConvertible." BitArray
> obviously does not implement IConvertable.
> If anyone has a good way of passing binary data into a stored
> procedure through a parameter array I'd appreciate it.

You might get a better answer by posting in a .NET or VB group. I don't know
what a BitArray is, but you can use the ADO Command object to execute stored
procedures with correctly typed parameters, which might be another
possiblity for you.

Simon

Bit column in FoxPro GUI

I have to pull data from a SQL app for a WIN-Form app in .NET, where data is
stored in FoxPro. Seems that the bit data type is not casting properly
through the ODBC driver back to FoxPro'
Any way to cast or convert a bit column? When I did case when IsPrint = 0
then ' 0' else '1' end IsPrint but that barfed?
Any ideas?How about CAST(bitcol AS int)?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Stephen Russell" <srussell@.lotmate.com> wrote in message
news:%23bEzNe6DFHA.328@.tk2msftngp13.phx.gbl...
>I have to pull data from a SQL app for a WIN-Form app in .NET, where data i
s
> stored in FoxPro. Seems that the bit data type is not casting properly
> through the ODBC driver back to FoxPro'
> Any way to cast or convert a bit column? When I did case when IsPrint = 0
> then ' 0' else '1' end IsPrint but that barfed?
> Any ideas?
>
>|||"Stephen Russell" <srussell@.lotmate.com> wrote in message
news:%23bEzNe6DFHA.328@.tk2msftngp13.phx.gbl...
> I have to pull data from a SQL app for a WIN-Form app in .NET, where data
is
> stored in FoxPro. Seems that the bit data type is not casting properly
> through the ODBC driver back to FoxPro'
cast (ap_noprint as int) ap_noprint
Worked fine.