|
It has been a very frustrating effort attempting to find the root cause of this problem. I have searched the web sites and there is no definitive explanation. Likewise, this same message has been posted on Microsoft's SQL Server forum. There have been many viewers, but no responders.
We are running a Visual Studio C++ application using Sql Server / ODBC. SQL Queries are formatted and exceuted from the C++ code.
This particular SQL Error occurs about once every few months. Since the time of the last error, I added additional debug statements which log the exact format of the SQL Query that is being executed.
This is the SQL query that just failed.
SELECT * FROM [LaneInventory] WHERE (LaneInventory.LocationName = 'LANE_06');
The query that failed is executed hundreds of times within a 24 hour period every day, with the only exception being the location name changes in the query. The same exact query identified above was executed successfully about 15 minutes prior to this failure.
The SQL Exception message is very misleading.
I am wondering if SQL Server gets into a confused state every one in a while, or maybe it is a problem with the ODBC driver. The C++ application code is running on Windows 2003.
AbbyDabby
|
|
|
|
|
I'm not expert on databases, but the error is "Attempt to open a table failed"...so is it possible that your problem is caused by two people accessing the same file at the same time...one of them failing to open it because the other one had it locked? Or is there some other scenario where that file could be locked or unavailable for any reason?
|
|
|
|
|
Hi,
I currently have a DataGrid which retrieves the Surname of a user into one of the columns using an SQL View.
I would like to have the SQL View retrieve both Surname AND Forename.
Here's the current view:
SELECT tblProject.inProjectID, tblProject.vchProjectName, tblUser.vchSurname, tblProject.dtStartDate, tblProject.dtCompletionDate
FROM tblProject INNER JOIN
tblUser ON tblProject.inProjectManagerID = tblUser.inUserID
The view allows the display of the Surname. I would like to display "Surname, Forename" i.e. "Smith, John"
I used the following query for application on a DropDownList:
"SELECT tblUser.inUserID, tblUser.vchSurname + ', ' + tblUser.vchForename AS ForenameANDSurname FROM tblUser ORDER BY tblUser.vchSurname"
I just can't seem to fit it into the View
Any Ideas?
Thanks
|
|
|
|
|
Dayekh wrote: I used the following query for application on a DropDownList:
How do u fil DropDownList???
Do u set DataSource,DataValueField,DataTextField???
|
|
|
|
|
Yes indeed, I set all three of them.
Remember, the data text field will be the new alias that you specified for the fields.. ie forename field + surname field = "Fullname"
|
|
|
|
|
ur alias column (alias columns is forename field + ', ' + surname field as fullname) have to be DataTextField of dropdownlist
i.e
forename field + ', ' + surname field as fullname<br />
<br />
DropDownList1.DataTextField = "fullname";
|
|
|
|
|
Sorry I dont think I made myself clear..
I have already succeeded in populating my dropdown list. It shows:
"Surname, Forename"
I am referring to doing the same for a datagrid column. The column is already populated using an SQL View as shown in original post. Instead of having the column display:
"Surname"
I want it to display:
"Forename, Surname"
see what I mean ?
|
|
|
|
|
in ur view instead of surname set forename and instead of forename set surname
i.e
select ........ forename + ', ' + surname as fullname<br />
<br />
DropDownList1.DataTextField = "fullname";
|
|
|
|
|
Thank you very much for your replies..
Works now!
Turns out I had to remove the following bold entry:
SELECT ..., tblUser.Surname, ... FROM ...
and place:
tblUser.Forename + ' ' + tblUser.Surname AS Fullname instead!
Lol, Thanks.. it helped a lot. At least just to show me how trivial this was!
|
|
|
|
|
Never mind dude u are welcome...
|
|
|
|
|
Hello,
I have two tables with the following fields:
1. Table "web_Content"
Fields: [ContentId] > Primary Key;
[ContentName];
[ContentPage].
2. Table "web_ContentLocalized"
Fields: [Content_LocalizedId] > Primary Key
[ContentId] > Joined to ContentId in table "web_Content"
[ContentCulture]
[ContentHtml]
I want to INSERT a new record in both databases.
What I mean is that a new record will add values to [ContentName];
[ContentPage]; [ContentCulture] and [ContentHtml].
[ContentId] and [Content_LocalizedId] are autonumbers.
[ContentId] in table "web_ContentLocalized" should be the same as in
[ContentId] of "web_Content" table.
Anyway, I tried but until now I was able to make this work.
This is what I have:
INSERT INTO web_Content ( ContentPage, ContentName )
SELECT web_Content.ContentPage, web_Content.ContentName
FROM web_Content INNER JOIN web_ContentLocalized ON
web_Content.ContentId = web_ContentLocalized.ContentId;
Thanks,
Miguel
|
|
|
|
|
An INSERT statement can only target one table.
It is possible to target an INSERT statement to a view in SQL Server if you're prepared to create an INSTEAD OF trigger on the view, but this trigger will have to be coded to perform an INSERT into each table separately.
The general way of handling this is to use the SCOPE_IDENTITY() function to discover the identity value of the last row inserted.
You could consider creating a stored procedure:
CREATE PROC uspInsertWebContentLocalized
(
@contentName varchar(n),
@contentPage varchar(n),
@contentCulture varchar(n),
@contentHtml varchar(n)
)
AS
INSERT INTO web_Content ( ContentName, ContentPage )
VALUES ( @contentName, @contentPage )
INSERT INTO web_ContentLocalized
( ContentId, ContentCulture, ContentHtml )
VALUES
( SCOPE_IDENTITY(), @contentCulture, @contentHtml )
|
|
|
|
|
Hi,
I want to search a DataSet (dataset contains several tables) for a specific value. (Writing a login method that shall verify if the user exists and has the correct password)
I am bit confused about; DataSet, BindingSource, DataTable etc.
thanx in advance
Regards
/Christoffer
|
|
|
|
|
What specifically are you asking?
You seem to know what a DataSet is...It is a collection of DataTables.
Or are you asking about connecting to a Data Source like an access database or something? In that case you would need to research command objects, connection objects, and data adapters. I'm sure you can find a bunch of articles about connecting to a datasource here at codeproject.
|
|
|
|
|
Hi,
Thanx for your reply.
What I am a bit confused about is once you have "imported" data into the DataSet how do you search for a value in the dataset? Is there a common/standard way to do this? I think of a DataSet as an interface to the datastorage and therefor expect methods like getDataByUniqueKey(), searchForData(DataTable table) etc. I now understand that this is not the case. So should I write an interface to the DataSet? Maybe the problem is that I do not fully understand the relations between TableAdapter, BindingSource, DataSet?!
:-/
Hope this clarify the issue/question?!
cheers
/Christoffer
|
|
|
|
|
I think you've probably had trouble finding information on this because you don't really search a DataSet...You would do the search on a DataTable. There are a number of ways to perform a search on a DataTable object, I'll tell you about one. First of all, since a DataSet is a collection of DataTable objects, you can reference a table IN a DataSet like this:
dsMyDataSet.Tables("myTableName")
or, if for example you knew the table you wanted was the first table inserted into the DataSet:
dsMyDataSet.Tables(0)
So one way to search the DataTable requires that you first have a primary key constraint on the table. If you got the data for this DataSet from a data base by using a DataAdapter and doing a .Fill the constraints are not necessarily carried over into the DataSet. You may have to do something like this:
With dsMyDataSet.Tables("dtMyTable")<br />
.Constraints.Add("pk", .Columns("PrimaryKeyColumnName"), True)<br />
End With
The "pk" parm gives a name to the new contraint for referencing it later, the .Columns("PrimaryKeyColumnName") parm specifies which column in the DataTable is the primary or unique key, and the True parm specifies that this is a primary key. This works when just one column makes up your primary key, if you have more than one column as a primary key the .Columns("PrimaryKeyColumnName") parm should be replaced by an array of DataColumns from the DataTable that compose the Primary Key.
Once you are sure that your DataTable has a primary key constraint you can search for a row like this:
Dim rowFound As DataRow<br />
rowFound = dt.Rows.Find("myKeyValue")
or if your primary key is a number:
Dim rowFound As DataRow<br />
rowFound = dt.Rows.Find(1003)
I hope this helps.
|
|
|
|
|
Hi again,
That helped!
Thank you very much for taking your time and explain the solution of the problem of mine.
cheers
/Christoffer
|
|
|
|
|
I m trying to execute the following store procedure
create Procedure sp_sys_getMax
@FieldId int,
@tablename varchar(255)
as
select Max(@FieldId) from @tablename
the following error is occuring:
Must declare the table variable "@tablename".
i want one store proc for all tables. plz help me in this.
|
|
|
|
|
create Procedure sp_sys_getMax<br />
@FieldId int,<br />
@tablename varchar(255)<br />
<br />
as<br />
<br />
select Max(@FieldId) from tablename
|
|
|
|
|
You can't pass table names as parameters. What you want to do will not work.
|
|
|
|
|
I'm not sure what you are passing as your first parameter, but if you make the following procedure and pass in the Field Name and Table Name, you should get what you're after.
create Procedure sp_sys_getMax
@FieldName varchar(50),
@tablename varchar(255)
as
declare @sql varchar(300)
set @sql = 'select Max(' + @FieldName + ') from ' + @tablename
exec(@sql)
GO
Be sure to read this article: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hello,
In my application i am Encrypting the mail ID in Dotnet using RijndaelManaged class and ICryptoTransform and storing it in SQL 2000 table.
I want to decrypt the same data(i.e Encrypted data in dotnet) in SQL 2000.
Is it possible to do to this. If so Can anybody suggest me on this.
With regards
Prashanth B.V
|
|
|
|
|
if i have three condition like a=b ,c=d ,y=z?
How i write in SQL code ?
if i write
SELECT
FROM
WHERE a=b AND c=d AND y=z
?
is it correct?
thanks
Best regards,
Chee ken
|
|
|
|
|
i.e
select * from tablename where column1= 'condition1' and column2= 'condition2' and column3= 'condition3'
|
|
|
|
|
Say for example you have two companys using the same database...but each table in the database has a company id so you can keep track of which company ownes the data...now the question is, I need to insert a record and return the id for that record, but IDENT_CURRENT is going to give me the current ID for that table...not respective of which company inserted the ID...so what is the best way of getting the correct id? Here is the wraper class so far...I dont mind if you re-use it in your projects, but help if you can please
Thanks in advance guys(and girls )
Public NotInheritable Class winSQLite
#Region " Public Types "
Public NotInheritable Class UpdateResultParam
#Region " Variables "
Private m_IDs As New ArrayList
Private m_NumAdded As Integer
Private m_NumDeleted As Integer
Private m_NumUpdated As Integer
Private m_Failed As Boolean
#End Region
#Region " Constructors "
Public Sub New()
m_NumAdded = 0
m_NumDeleted = 0
m_NumUpdated = 0
m_Failed = False
End Sub
Public Sub New(ByVal ids As ArrayList, ByVal numAdded As Integer, ByVal numDeleted As Integer, ByVal numUpdated As Integer, ByVal failed As Boolean)
m_IDs = ids
m_NumAdded = numAdded
m_NumDeleted = numDeleted
m_NumUpdated = numUpdated
m_Failed = failed
End Sub
Public Sub New(ByVal id As Integer, ByVal numAdded As Integer, ByVal numDeleted As Integer, ByVal numUpdated As Integer, ByVal failed As Boolean)
m_IDs = New ArrayList
m_IDs.Add(id)
m_NumAdded = numAdded
m_NumDeleted = numDeleted
m_NumUpdated = numUpdated
m_Failed = failed
End Sub
Public Sub New(ByVal numAdded As Integer, ByVal numDeleted As Integer, ByVal numUpdated As Integer, ByVal failed As Boolean)
m_NumAdded = numAdded
m_NumDeleted = numDeleted
m_NumUpdated = numUpdated
m_Failed = failed
End Sub
#End Region
#Region " Propertys "
Public ReadOnly Property IDs() As Integer()
Get
Return m_IDs.ToArray(GetType(Integer))
End Get
End Property
Public ReadOnly Property NumAdded() As Integer
Get
Return m_NumAdded
End Get
End Property
Public ReadOnly Property NumDeleted() As Integer
Get
Return M_NumDeleted
End Get
End Property
Public ReadOnly Property NumUpdated() As Integer
Get
Return m_NumUpdated
End Get
End Property
Public ReadOnly Property Failed() As Boolean
Get
Return m_Failed
End Get
End Property
#End Region
#Region " Functions "
Public Sub Combine(ByVal p2 As UpdateResultParam)
m_IDs.AddRange(p2.m_IDs)
m_NumAdded += p2.m_NumAdded
m_NumDeleted += p2.m_NumDeleted
m_NumUpdated += p2.m_NumUpdated
m_Failed = m_Failed Or p2.m_Failed
End Sub
#End Region
#Region " Shared "
Public Shared Function Combine(ByVal p1 As UpdateResultParam, ByVal p2 As UpdateResultParam) As UpdateResultParam
Dim theIDs As New ArrayList
theIDs.AddRange(p1.m_IDs)
theIDs.AddRange(p2.m_IDs)
Return New UpdateResultParam(theIDs, p1.m_NumAdded + p2.m_NumAdded, p1.m_NumDeleted + p2.m_NumDeleted, p1.NumUpdated + p2.NumUpdated, p1.Failed Or p2.Failed)
End Function
#End Region
End Class
#End Region
#Region " Variables "
Private Shared m_DefConStr As String = Nothing
#End Region
#Region " Propertys "
Public Shared Property DefaultConnectionString() As String
Get
Return m_DefConStr
End Get
Set(ByVal value As String)
m_DefConStr = value
End Set
End Property
#End Region
#Region " Constructor Lock Out "
Private Sub New()
End Sub
#End Region
#Region " User Routines "
#Region " With Con Str "
#Region " Update "
Public Shared Function ID_UpdateRows(ByVal conStr As String, ByVal ds As DataSet) As UpdateResultParam
Dim retParam As New UpdateResultParam
For Each r As DataRow In ds.Tables(0).Rows
retParam.Combine(ID_UpdateRow(conStr, r))
Next r
Return retParam
End Function
Public Shared Sub UpdateRows(ByVal conStr As String, ByVal ds As DataSet)
For Each r As DataRow In ds.Tables(0).Rows
UpdateRow(conStr, r)
Next r
End Sub
Public Shared Function ID_UpdateRow(ByVal conStr As String, ByVal r As DataRow) As UpdateResultParam
Dim retParam As UpdateResultParam
Select Case r.RowState
Case DataRowState.Added
retParam = New UpdateResultParam(ID_InsertRow(conStr, r), 1, 0, 0, False)
Case DataRowState.Deleted
r.RejectChanges()
DeleteRow(conStr, r)
retParam = New UpdateResultParam(0, 1, 0, False)
Case DataRowState.Modified
ExecuteNonQuery(conStr, UpdateRowSQL(r))
retParam = New UpdateResultParam(0, 0, 1, False)
Case Else
retParam = New UpdateResultParam(0, 0, 0, False)
End Select
Return retParam
End Function
Public Shared Sub UpdateRow(ByVal conStr As String, ByVal r As DataRow)
Select Case r.RowState
Case DataRowState.Added
InsertRow(conStr, r)
Case DataRowState.Deleted
DeleteRow(conStr, r)
Case DataRowState.Modified
ExecuteNonQuery(conStr, UpdateRowSQL(r))
End Select
End Sub
#End Region
#Region " Insert "
Public Shared Sub InsertRows(ByVal conStr As String, ByVal ds As DataSet)
For Each r As DataRow In ds.Tables(0).Rows
InsertRow(conStr, r)
Next r
End Sub
Public Shared Function ID_InsertRows(ByVal conStr As String, ByVal ds As DataSet) As Integer()
Dim retIDs As New ArrayList
For Each r As DataRow In ds.Tables(0).Rows
retIDs.Add(ID_InsertRow(conStr, r))
Next r
Return retIDs.ToArray(GetType(Integer))
End Function
Public Shared Sub InsertRow(ByVal conStr As String, ByVal r As DataRow)
ExecuteNonQuery(conStr, InsertRowSQL(r))
End Sub
Public Shared Function ID_InsertRow(ByVal conStr As String, ByVal r As DataRow) As Integer
ExecuteNonQuery(conStr, InsertRowSQL(r))
Return GetCurrentID(conStr, r.Table.TableName)
End Function
#End Region
#Region " Delete "
Public Shared Sub DeleteRows(ByVal conStr As String, ByVal ds As DataSet)
For Each r As DataRow In ds.Tables(0).Rows
DeleteRow(conStr, r)
Next r
End Sub
Public Shared Sub DeleteRow(ByVal conStr As String, ByVal r As DataRow)
Dim pk As String = r.Table.PrimaryKey(0).ColumnName
DeleteID(conStr, pk, r.Item(pk), r.Table.TableName)
End Sub
Public Shared Sub DeleteID(ByVal conStr As String, ByVal pk As String, ByVal pkv As Integer, ByVal tbl As String)
ExecuteNonQuery(conStr, "Delete From " & tbl & " Where " & pk & " = " & pkv)
End Sub
#End Region
#Region " GetDatasets "
#Region " Typed "
Public Shared Function DR_GetTypedDataset(ByVal conStr As String, ByVal qry As String, ByVal dsName As String) As DataSet
Dim theCmd As SqlClient.SqlCommand = New SqlClient.SqlConnection(conStr).CreateCommand
Dim reader As IDataReader
Dim ds As DataSet
theCmd.CommandText = qry
theCmd.Connection.Open()
reader = theCmd.ExecuteReader(CommandBehavior.CloseConnection)
ds = DataReaderToDataSet(reader, dsName)
reader.Close()
Return ds
End Function
Public Shared Function GetTypedDataset(ByVal conStr As String, ByVal qry As String, ByVal dsName As String) As DataSet
Dim theCmd As SqlClient.SqlCommand = New SqlClient.SqlConnection(conStr).CreateCommand
Dim ds As New DataSet
theCmd.CommandText = qry
theCmd.Connection.Open()
With New SqlClient.SqlDataAdapter(theCmd)
.Fill(ds, dsName)
End With
theCmd.Connection.Close()
Return ds
End Function
#End Region
#Region " UnTyped "
Public Shared Function DR_GetDataset(ByVal conStr As String, ByVal qry As String) As DataSet
Dim theCmd As SqlClient.SqlCommand = New SqlClient.SqlConnection(conStr).CreateCommand
Dim reader As IDataReader
Dim ds As DataSet
theCmd.CommandText = qry
theCmd.Connection.Open()
reader = theCmd.ExecuteReader(CommandBehavior.CloseConnection)
ds = DataReaderToDataSet(reader, "DataSet")
reader.Close()
Return ds
End Function
Public Shared Function GetDataset(ByVal conStr As String, ByVal qry As String) As DataSet
Dim theCmd As SqlClient.SqlCommand = New SqlClient.SqlConnection(conStr).CreateCommand
Dim ds As New DataSet
theCmd.CommandText = qry
theCmd.Connection.Open()
With New SqlClient.SqlDataAdapter(theCmd)
.Fill(ds, "DataSet")
End With
theCmd.Connection.Close()
Return ds
End Function
#End Region
#End Region
#Region " Executes "
Public Shared Function Execute(ByVal conStr As String, ByVal qry As String) As DataSet
Return DR_GetDataset(conStr, qry)
End Function
Public Shared Function DR_Execute(ByVal conStr As String, ByVal qry As String) As DataSet
Return GetDataset(conStr, qry)
End Function
Public Shared Function ExecuteNonQuery(ByVal conStr As String, ByVal qry As String) As Integer
Dim ret As Integer
With New SqlClient.SqlConnection(conStr).CreateCommand
.CommandText = qry
.Connection.Open()
ret = .ExecuteNonQuery()
.Connection.Close()
End With
Return ret
End Function
Public Shared Function ExecuteScalar(ByVal conStr As String, ByVal qry As String) As Object
Dim ret As Object
With New SqlClient.SqlConnection(conStr).CreateCommand
.CommandText = qry
.Connection.Open()
ret = .ExecuteScalar
.Connection.Close()
End With
Return ret
End Function
#End Region
Public Shared Function GetCurrentID(ByVal conStr As String, ByVal tbl As String) As Integer
Return ExecuteScalar(conStr, "SELECT IDENT_CURRENT('" & tbl & "')")
End Function
#End Region
#Region " Without Con Str "
#Region " Update "
Public Shared Function ID_UpdateRows(ByVal ds As DataSet) As UpdateResultParam
Return ID_UpdateRows(m_DefConStr, ds)
End Function
Public Shared Sub UpdateRows(ByVal ds As DataSet)
UpdateRows(m_DefConStr, ds)
End Sub
Public Shared Function ID_UpdateRow(ByVal r As DataRow) As UpdateResultParam
Return ID_UpdateRow(m_DefConStr, r)
End Function
Public Shared Sub UpdateRow(ByVal r As DataRow)
UpdateRow(m_DefConStr, r)
End Sub
#End Region
#Region " Insert "
Public Shared Sub InsertRows(ByVal ds As DataSet)
InsertRows(m_DefConStr, ds)
End Sub
Public Shared Function ID_InsertRows(ByVal ds As DataSet) As Integer()
Return ID_InsertRows(m_DefConStr, ds)
End Function
Public Shared Sub InsertRow(ByVal r As DataRow)
InsertRow(m_DefConStr, r)
End Sub
Public Shared Function ID_InsertRow(ByVal r As DataRow) As Integer
Return ID_InsertRow(m_DefConStr, r)
End Function
#End Region
#Region " Delete "
Public Shared Sub DeleteRows(ByVal ds As DataSet)
DeleteRows(m_DefConStr, ds)
End Sub
Public Shared Sub DeleteRow(ByVal r As DataRow)
DeleteRow(m_DefConStr, r)
End Sub
Public Shared Sub DeleteID(ByVal pk As String, ByVal pkv As Integer, ByVal tbl As String)
DeleteID(m_DefConStr, pk, pkv, tbl)
End Sub
#End Region
#Region " GetDataset "
#Region " Typed "
Public Shared Function DR_GetTypedDataset(ByVal qry As String, ByVal dsName As String) As DataSet
Return DR_GetTypedDataset(m_DefConStr, qry, dsName)
End Function
Public Shared Function GetTypedDataset(ByVal qry As String, ByVal name As String) As DataSet
Return GetTypedDataset(m_DefConStr, qry, name)
End Function
#End Region
#Region " UnTyped "
Public Shared Function DR_GetDataset(ByVal qry As String) As DataSet
Return DR_GetDataset(m_DefConStr, qry)
End Function
Public Shared Function GetDataset(ByVal qry As String) As DataSet
Return GetDataset(m_DefConStr, qry)
End Function
#End Region
#End Region
#Region " Executes "
Public Shared Function Execute(ByVal qry As String) As DataSet
Return Execute(m_DefConStr, qry)
End Function
Public Shared Function DR_Execute(ByVal qry As String) As DataSet
Return DR_Execute(m_DefConStr, qry)
End Function
Public Shared Function ExecuteNonQuery(ByVal qry As String) As Integer
Return ExecuteNonQuery(m_DefConStr, qry)
End Function
Public Shared Function ExecuteScalar(ByVal qry As String) As Object
Return ExecuteScalar(m_DefConStr, qry)
End Function
#End Region
Public Shared Function GetCurrentID(ByVal tbl As String) As Integer
Return GetCurrentID(m_DefConStr, tbl)
End Function
#End Region
#End Region
#Region " Helpers "
Public Shared Function DataReaderToDataSet(ByVal rdr As IDataReader, ByVal tblName As String) As DataSet
Dim tbl As New DataTable(tblName)
Dim count As Integer = rdr.FieldCount
Dim items(count - 1) As Object
Dim ds As New DataSet
For i As Integer = 0 To count - 1
tbl.Columns.Add(rdr.GetName(i), rdr.GetFieldType(i))
Next i
While rdr.Read
rdr.GetValues(items)
tbl.LoadDataRow(items, True)
End While
ds.Tables.Add(tbl)
Return ds
End Function
Public Shared Function InsertRowSQL(ByVal r As DataRow) As String
Dim tbl As DataTable = r.Table
Dim qry As String = "INSERT INTO " & tbl.TableName & "("
For Each c As DataColumn In tbl.Columns
If Not c.AutoIncrement Then qry &= c.ColumnName & ","
Next c
qry = qry.TrimEnd(",") & ") VALUES("
For i As Integer = 0 To r.Table.Columns.Count - 1
Dim c As DataColumn = r.Table.Columns(i)
If Not c.AutoIncrement Then
If c.DataType Is Type.GetType("System.String") Then
qry &= "'" & r.Item(i) & "',"
Else : qry &= r.Item(i).ToString & ","
End If
End If
Next i
Return qry.TrimEnd(",") & ")"
End Function
Public Shared Function UpdateRowSQL(ByVal r As DataRow) As String
Dim qry As String = "UPDATE " & r.Table.TableName & " Set "
For i As Integer = 0 To r.Table.Columns.Count - 1
Dim c As DataColumn = r.Table.Columns(i)
If Not c.AutoIncrement Then
If c.DataType Is Type.GetType("System.String") Then
qry &= c.ColumnName & "='" & r.Item(i) & "',"
Else : qry &= c.ColumnName & "=" & r.Item(i).ToString & ","
End If
End If
Next i
Return qry.TrimEnd(",")
End Function
Public Shared Function IsDSEmpty(ByVal ds As DataSet) As Boolean
If Not ds Is Nothing Then
If ds.Tables.Count > 0 Then
If ds.Tables(0).Rows.Count > 0 Then
Return False
End If
End If
End If
Return True
End Function
#End Region
End Class
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|