Saturday, February 25, 2012

Creating a data source on the server to connect to SQL SERVER.

My question is what is the proper way to do this? I have been try the ways that it is instructing me to do.

By creating the name, then I go to a list of potential sources, one being: the local, then another being: the actual domain on the network, last one being: the name of the created data source. I have already tried the local & domain, I will try the last one.

But, my question is if this selection is not going to connect to SQL SERVER. Then, "What should I do within the server to make this connection possible to a client computer look for the access?"

Hi,

I Did not understand your explanation. But anyway, if you want to let clients access SQL Server, you would have to do nothing more than

1.Enabling remote connection (In SQL Server 2005 this is disabled by default, for SQL 2000 its enabled) (see my website for a walkthrough)
2.If you are running on a dfferent port than the default one (1433) you would have to start SQL Browser on the Server (for SQL2k only)

On the client you can use on e of the connections strings here:

www.connectionstrings.com

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

creating a data driven hierarchial navigation

Hi need to create navigation that gets populated via database and is role based. below is the sql

CREATETABLE [TopMenu](

[MenuID] [int]IDENTITY(1, 1)NOTNULL,

[Text] [varchar](50)COLLATE SQL_Latin1_General_CP1_CI_ASNULL,

[Description] [varchar](255)COLLATE SQL_Latin1_General_CP1_CI_ASNULL,

[ParentID] [int]NULL,

CONSTRAINT [PK_Menu]PRIMARYKEYCLUSTERED

(

[MenuID]

)ON [PRIMARY]

)ON [PRIMARY]

GO

INSERTINTO TopMENU

Select'Property','Property',NULL

UNION ALLSelect'Portfolio','Portfolio',NULL

UNION ALLSelect'Capital Expenditure','PortfolioCapex', 1

UNION ALLSelect'Depreciation','PortfolioDepreciation', 1

UNION ALLSelect'Condition Audit','PortfolioCondition', 1

UNION ALLSelect'Historical Expenditure','PortfolioHisEx', 1

UNION ALLSelect'Property Details','PropertyDetail', 2

UNION ALLSelect'Assets','PropertyAsset', 2

UNION ALLSelect'Depreciation','PropertyDepreciation', 2

UNION ALLSelect'Capital Expenditure','PropertyExpenditure', 2

UNION ALLSelect'Insurance','PropertyInsurance', 2

UNION ALLSelect'Documents','PropertyDocuments', 2

UNION ALLSelect'Capex','PortfolioCapex', 3

UNION ALLSelect'Graph','PortfolioCapexGraph', 3

UNION ALLSelect'Graph','PortfolioDepreciationGraph', 4

UNION ALLSelect'Current Depreciation','PortfolioDepreciation', 4

UNION ALLSelect'WDV & Depreciation','PortfolioDepreciationWDV', 4

UNION ALLSelect'Assets','PropertyAsset', 8

UNION ALLSelect'Capex','PropertyCapex', 8

UNION ALLSelect'Depreciation','PropertyDepreciation', 8

UNION ALLSelect'Condition','PropertyCondition', 8

UNION ALLSelect'Expenditure','PropertyExpenditure', 8

UNION ALLSelect'Disposed','PropertyDisposed', 8

UNION ALLSelect'Capital Ex','PropertyExpenditure', 10

UNION ALLSelect'Capital Ex Graph','PropertyExpenditureGraph', 10

GO

now clearly, I will have two top level navigation

property and portfolio. both property will have subsequent navigation and those subsequest navigation may or may not have another sets of navigation.

I need to display in a row style not in a drop down style for eg. If I am in portfolio link the navigation structure should be as below

Portfolio

Capital Expenditure | Depreciation | Condition Audit | Historical Expenditure

Capex | Graph

by default Capex should be selected. it should also highlight Portfolio, Capital Expenditure and Capex as Capex's parent is Capital Expenditure and Portfolio

I was thinking of using a 3 level datagrid. could someone please help me I am using asp.net 2.0 web application project with vb.net and sql server 2005

thanks in advance

Have you looked at the menu class available from the toolbar? I know it works with a hierarchical xml file, it might work with a database source also.

If it does, I think it will do what you want UI-wise.

|||I am doing it in webform not windows form. does it support that?|||

foremorecoast:

I am doing it in webform not windows form. does it support that?

This is an asp.net forum, not a windows forms forum. So I wasn't talking about windows forms. :)

As for whether it supports database-supplied values instead of xml files for the menu entries, you'll have to look that up. It's what I would do first if I had to code a solution like that. But I don't, and you do, so you can look it up and tell us about what you found. :)

|||

the problem here is not the datasource type but the logic on how to display second level navigation and third level navigation based on what is clicked. i.e. property or portfolio. I have seen lots of article which shows how to create a data driven menu using javascript downdown but i want second and third navigation to be static based on what is clicked( either property or portfolio).

please help

|||

I am thinking of alternative solution using 3 level datalist but its not working as there is no onclick property so that based on property link or portfolio link click i could display their childrens and based on their children click i could display their sub childs.

can anyone please help me?

|||

Hi! I used below method to implement 3 level navigation. but I now have a problem of maintaining the selected state of the item after postback.

when user logs in I need to somehow set the default page pointing to

Portfolio

Assets

Capex

and at the same time i need to show those three links active.

each page should go to differnt url with parameter. below are my codes. please help.

aspx

<asp:DataList ID="dlParent" runat="server" RepeatDirection="Horizontal" DataKeyField="MenuId" OnSelectedIndexChanged="parentselectedindexchanged" Font-Names="Trebuchet MS" Font-Size="Smaller" ForeColor="#404040">
<ItemTemplate>
<asp:LinkButton ID="lnkParent" runat="server" CommandName="select" Text='<%# DataBinder.Eval(Container, "DataItem.Text")%>'></asp:LinkButton>
</ItemTemplate>
<SelectedItemStyle BackColor="Silver" />
</asp:DataList>
<asp:dataList id="dlChild" runat="server" RepeatDirection="Horizontal" DataKeyField="MenuId" OnSelectedIndexChanged="childselectedindexchanged" Font-Names="Trebuchet MS" Font-Size="Smaller">
<ItemTemplate>
<asp:LinkButton ID="lnkChild" runat="server" CommandName="select" Text='<%# DataBinder.Eval(Container, "DataItem.Text")%>'></asp:LinkButton>
</ItemTemplate>
<SelectedItemStyle BackColor="Silver" />
</asp:dataList>
<asp:dataList id="dlSubChild" runat="server" RepeatDirection="Horizontal" Font-Names="Trebuchet MS" Font-Size="Smaller" >
<ItemTemplate>
<asp:LinkButton ID="lnkSubChild" runat="server" CommandName="select" Text='<%# DataBinder.Eval(Container, "DataItem.Text")%>'></asp:LinkButton>
</ItemTemplate>
<SelectedItemStyle BackColor="Silver" />
</asp:dataList>


code behind
--
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myDal As New clsDAL
Dim dsParent As DataSet
'Dim selParent As Integer = -1
'dlParent.SelectedIndex = selParent
If Not IsPostBack Then

dsParent = myDal.getSubMenuItems(0)

If Not dsParent Is Nothing Then
dlParent.DataSource = dsParent
dlParent.DataBind()
End If

End If
End Sub

Protected Function BuildUrl(ByVal field1 As Integer) As String
Dim baseUrl As String
baseUrl = "menu.aspx"
Return String.Format("{0}?navId={1}", baseUrl, field1)
End Function

Public Sub parentselectedindexchanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mydal As New clsDAL
Dim NavId As Integer
'Dim selChild As Integer = -1
'dlChild.SelectedIndex = selChild
Dim dsChild As New DataSet
Try
NavId = CInt(dlParent.DataKeys(dlParent.SelectedIndex))

dsChild = mydal.getSubMenuItems(NavId)
dlChild.DataSource = dsChild
dlChild.DataBind()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub

Public Sub childselectedindexchanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mydal As New clsDAL
Dim NavId As Integer
'Dim selSubChild As Integer = -1
'dlSubChild.SelectedIndex = selSubChild
Dim dsSubChild As New DataSet
Try
NavId = CInt(dlChild.DataKeys(dlChild.SelectedIndex))
dsSubChild = mydal.getSubMenuItems(NavId)
dlSubChild.DataSource = dsSubChild
dlSubChild.DataBind()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub

|||

can someone at least point me to write direction?

|||

You could save the entire object in session cache and restore it with each postback.

Sorry, I don't know how to make it pre-open to a given location.

|||

could you please show me how you will do it as i have never used cache to store the datalist. a code snippet will be of great help.

cheers

Creating a custom word-breaker and stemmer

Does anyone know of any links to articles or information on creating a
custom word-breaker and stemmer for full-text search on SQL 2005?
In the meantime I'll keep Googling.
Thanks
Microsoft.com has some articles.
http://msdn2.microsoft.com/en-gb/library/ms691035.aspx
http://msdn2.microsoft.com/en-us/library/ms916793.aspx
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Mike C#" <xyz@.xyz.com> wrote in message
news:e5e4OywPHHA.3344@.TK2MSFTNGP02.phx.gbl...
> Does anyone know of any links to articles or information on creating a
> custom word-breaker and stemmer for full-text search on SQL 2005?
> In the meantime I'll keep Googling.
> Thanks
>
|||"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:%23IUb7byPHHA.856@.TK2MSFTNGP05.phx.gbl...
> Microsoft.com has some articles.
> http://msdn2.microsoft.com/en-gb/library/ms691035.aspx
> http://msdn2.microsoft.com/en-us/library/ms916793.aspx
Thanks Hilary. BTW the folks here at work want to start doing some
full-text searching on certain items, and I've pointed them to your articles
for answers to a lot of their questions. Do you have a book on it, and if
so where can I get a copy?
Thanks again
|||The book is as yet unpublished.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Mike C#" <xyz@.xyz.com> wrote in message
news:OmbJ0czPHHA.2312@.TK2MSFTNGP04.phx.gbl...
> "Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
> news:%23IUb7byPHHA.856@.TK2MSFTNGP05.phx.gbl...
> Thanks Hilary. BTW the folks here at work want to start doing some
> full-text searching on certain items, and I've pointed them to your
> articles for answers to a lot of their questions. Do you have a book on
> it, and if so where can I get a copy?
> Thanks again
>
|||Please post when it's out, we could definitely use it.
Thanks
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:ubTWVadQHHA.4276@.TK2MSFTNGP02.phx.gbl...
> The book is as yet unpublished.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "Mike C#" <xyz@.xyz.com> wrote in message
> news:OmbJ0czPHHA.2312@.TK2MSFTNGP04.phx.gbl...
>
|||Mike I had a contract with Apress to put one out several years ago - it
focused on Indexing Services. I wrote 912 pages and then .Net happened. I
then got more interested in replication and never updated it for .Net. Nor
did I complete a chapter on SharePoint. I just don't think the demand is
there for a book on search at this time. NWSU did express an interest in it
as well, but I really have moved on to other things.
If you want to read the 912 pages just ask. I wrote a chapter on SQL FTS
2005 for SQL Server 2005 Bible, but it was based on the late betas/CTPs, and
SP 1 brought a few changes.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Mike C#" <xyz@.xyz.com> wrote in message
news:u8$Z40vQHHA.496@.TK2MSFTNGP06.phx.gbl...
> Please post when it's out, we could definitely use it.
> Thanks
> "Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
> news:ubTWVadQHHA.4276@.TK2MSFTNGP02.phx.gbl...
>
|||I would LOVE to read the 912 pages. Can you email it to me?
jsheehan@.groceryshopping.net
"Hilary Cotter" wrote:

> Mike I had a contract with Apress to put one out several years ago - it
> focused on Indexing Services. I wrote 912 pages and then .Net happened. I
> then got more interested in replication and never updated it for .Net. Nor
> did I complete a chapter on SharePoint. I just don't think the demand is
> there for a book on search at this time. NWSU did express an interest in it
> as well, but I really have moved on to other things.
> If you want to read the 912 pages just ask. I wrote a chapter on SQL FTS
> 2005 for SQL Server 2005 Bible, but it was based on the late betas/CTPs, and
> SP 1 brought a few changes.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "Mike C#" <xyz@.xyz.com> wrote in message
> news:u8$Z40vQHHA.496@.TK2MSFTNGP06.phx.gbl...
>
>
|||Me too, sent you an email Hilary. Thanks!
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:ehwe9w0QHHA.4476@.TK2MSFTNGP05.phx.gbl...
> Mike I had a contract with Apress to put one out several years ago - it
> focused on Indexing Services. I wrote 912 pages and then .Net happened. I
> then got more interested in replication and never updated it for .Net. Nor
> did I complete a chapter on SharePoint. I just don't think the demand is
> there for a book on search at this time. NWSU did express an interest in
> it as well, but I really have moved on to other things.
> If you want to read the 912 pages just ask. I wrote a chapter on SQL FTS
> 2005 for SQL Server 2005 Bible, but it was based on the late betas/CTPs,
> and SP 1 brought a few changes.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "Mike C#" <xyz@.xyz.com> wrote in message
> news:u8$Z40vQHHA.496@.TK2MSFTNGP06.phx.gbl...
>

Creating a custom transformation component Walkthrough

Microsoft published a "Creating a custom transformation component Walkthrough" published on

http://www.microsoft.com/downloads/details.aspx?FamilyID=1c2a7dd2-3ec3-4641-9407-a5a337bea7d3&DisplayLang=en

Does anyone know where to get the Hands-On Lab Files mentioned?

Thanks

Alex

I could not see any mention of files over and above the word document. There are plenty of samples available separately on MS Downloads, just search for SSIS.|||

On page 15, Task 1, Step 1 a path "c:\ssis hands-on-lab\scratch\.... " is mentioned. I just wanted to take a look at the regcomponent shown in setp 3.

Thanks anyway

|||

You create that yourself by going through pages 1 to 14!

-Jamie

|||http://www.microsoft.com/downloads/details.aspx?FamilyID=fc4de21d-9c5b-4b1d-aeef-ce43aadab4e4&DisplayLang=en

Creating a custom transformation component Walkthrough

Microsoft published a "Creating a custom transformation component Walkthrough" published on

http://www.microsoft.com/downloads/details.aspx?FamilyID=1c2a7dd2-3ec3-4641-9407-a5a337bea7d3&DisplayLang=en

Does anyone know where to get the Hands-On Lab Files mentioned?

Thanks

Alex

I could not see any mention of files over and above the word document. There are plenty of samples available separately on MS Downloads, just search for SSIS.|||

On page 15, Task 1, Step 1 a path "c:\ssis hands-on-lab\scratch\.... " is mentioned. I just wanted to take a look at the regcomponent shown in setp 3.

Thanks anyway

|||

You create that yourself by going through pages 1 to 14!

-Jamie

|||http://www.microsoft.com/downloads/details.aspx?FamilyID=fc4de21d-9c5b-4b1d-aeef-ce43aadab4e4&DisplayLang=en

Creating a custom resolver with VB.NET

Someone posted the question "Can anyone point me towards a source code
listing for a working replication custom resolver written in .Net?" Here is
an example that I have written.
Custom resolvers are created by adding a reference to the Microsoft SQL
Replication Conflict Resolver Library, replrec.dll. Unfortunately, the .NET
type library importer incorrectly defines the buffer parameter of methods
GetSourceColumnValue, GetDestinationColumnValue, and SetColumn to be the
address of an Object. For COM interfaces, which is what replrec.dll is
supposed to be, that implies a COM-VARIANT parameter passing mechanism, but
this is not what Replrec passes back. Replrec is simply passing back the
address of a buffer containing the column value which you have to decode.
So the solution involves correcting the method definitions so that a buffer
address can be passed and using the .NET Marshal routines to create the
buffer and move bytes out of the buffer.
Here are the steps involved, followed by a code example that resolves
conflicts by using the column values from the row with the latest date in
user defined column ModifyDate.
1. Open a Visual Studio .NET 2003 Command Prompt
2. tlbimp "c:\Program Files\Microsoft SQL Server\80\COM\replrec.dll"
/OUT:SQLResolver_import.dll
3. ildasm "SQLResolver_import.dll" /OUT=SQLResolver.il
4. Change line "[out] object& marshal( struct) pvBuffer" for the methods
GetSourceColumnValue, GetDestinationColumnValue, and SetColumn to "[out]
int32 pvBuffer"
5. ilasm SQLResolver.il /OUT=SQLResolver.dll /dll
6. Create a new .NET Windows Control Library project
7. Remove the wizard generated control
8. Use "Add New Item..." to add a new COM class
9. Add reference to SQLResolver.dll created in step #5
Imports System.Text
Imports SQLResolver
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.MarshalAsAttribute
Imports SQLResolver.REPOLE_CHANGE_TYPE
Imports SQLResolver.REPOLE_COLSTATUS_TYPE
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Implements SQLResolver.IVBCustomResolver
Private Const MAX_BUFFER_SIZE As Integer = 1048576
Private Const MAX_NAME_LENGTH As Integer = 128
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "825818F7-3531-4524-8B07-72343EFDC8AB"
Public Const InterfaceId As String =
"CECFBB8F-584F-4733-9373-B69AFA6F117F"
Public Const EventsId As String = "5D55BA40-A438-4FD4-BA8B-05095DC89948"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Sub GetHandledStates(ByRef ResolverBm As Integer) Implements
IVBCustomResolver.GetHandledStates
ResolverBm = REPOLEUpdateConflicts
End Sub
Public Sub Reconcile(ByVal pRowChange As IReplRowChange, ByVal dwFlags As
Integer, ByVal pvReserved As IReplRowChange) Implements
IVBCustomResolver.Reconcile
Dim cntColumns As Integer
Dim intColumn As Integer
Dim strColumnName As String
Dim strLogMessage As String
Dim WinningData As Object
Dim blnSourceIsWinner As Boolean
Dim ColStatus As SQLResolver.REPOLE_COLSTATUS_TYPE
Dim intBufferLenActual As Integer
Dim intBufferLen As Integer
Dim strDestinationDateTime As String
Dim strSourceDateTime As String
Dim strDestinationUser As String
Dim strSourceUser As String
Dim myBuffer As IntPtr = Marshal.AllocHGlobal(MAX_BUFFER_SIZE)
Dim strMsg As String
'If Not Debugger.IsAttached Then
' Debugger.Launch()
'Else
' Debugger.Break()
'End If
Call pRowChange.GetNumColumns(cntColumns)
For intColumn = 1 To cntColumns
strColumnName = " ".PadRight(MAX_NAME_LENGTH)
' strColumnName.PadRight(OSQL_SYSNAME_SET, Chr(vbNull))
Call pRowChange.GetColumnName(intColumn, strColumnName, MAX_NAME_LENGTH)
' strColumnName.TrimEnd(Chr(vbNull))
strColumnName = strColumnName.TrimEnd()
If (String.Compare(strColumnName, "ModifyDate", True) = 0) Then
pRowChange.GetDestinationColumnValue(intColumn, myBuffer.ToInt32,
MAX_BUFFER_SIZE, intBufferLenActual)
strDestinationDateTime = ConvertBufferToDateString(myBuffer)
pRowChange.GetSourceColumnValue(intColumn, myBuffer.ToInt32,
MAX_BUFFER_SIZE, intBufferLenActual)
strSourceDateTime = ConvertBufferToDateString(myBuffer)
If strSourceDateTime > strDestinationDateTime Then
blnSourceIsWinner = True
Else
blnSourceIsWinner = False
End If
End If
If (String.Compare(strColumnName, "ModifyUser", True) = 0) Then
pRowChange.GetDestinationColumnValue(intColumn, myBuffer.ToInt32,
MAX_BUFFER_SIZE, intBufferLenActual)
strDestinationUser = ConvertBufferToString(myBuffer, intBufferLenActual)
pRowChange.GetSourceColumnValue(intColumn, myBuffer.ToInt32,
MAX_BUFFER_SIZE, intBufferLenActual)
strSourceUser = ConvertBufferToString(myBuffer, intBufferLenActual)
End If
Next intColumn
For intColumn = 1 To cntColumns
'Get the column status of each column
pRowChange.GetColumnStatus(intColumn, ColStatus)
' If the column has been updated at both the Publisher and Subscriber
If (ColStatus = REPOLEColumn_UpdatedWithConflict) Then
If blnSourceIsWinner Then
pRowChange.CopyColumnFromSource(intColumn)
End If
' For columns that have been updated without any changes, copy column
values from source
ElseIf (ColStatus = REPOLEColumn_UpdatedNoConflict) Then
pRowChange.CopyColumnFromSource(intColumn)
' For columns that have not been updated - do nothing.
ElseIf (ColStatus = REPOLEColumn_NotUpdated) Then
End If
Next intColumn
' Log conflict and call the UpdateRow method to commit all the column value
changes.
'
If strDestinationDateTime.Length > 0 And strDestinationUser.Length > 0 Then
If blnSourceIsWinner Then
strMsg = "Losing update(s) made by " & strDestinationUser
Else
strMsg = "Losing update(s) made by " & strSourceUser
End If
End If
pRowChange.LogConflict(REPOLE_BOOL.REPOLEBool_TRUE ,
REPOLE_CONFLICT_TYPE.REPOLEConflict_ColumnUpdateCo nflict,
REPOLE_BOOL.REPOLEBool_FALSE, strMsg, REPOLE_BOOL.REPOLEBool_FALSE)
Call pRowChange.UpdateRow()
Marshal.FreeHGlobal(myBuffer)
End Sub
Private Function ConvertBufferToDateString(ByVal p As IntPtr) As String
Dim s As String = String.Empty
Dim i(7) As Short
Dim j As Integer
Marshal.Copy(p, i, 0, i.Length)
s = i(0).ToString '4 digit Year
For j = 1 To i.GetUpperBound(0)
s &= i(j).ToString.PadLeft(2, "0"c)
Next
ConvertBufferToDateString = s
End Function
Private Function ConvertBufferToString(ByVal p As IntPtr, ByVal
intBufferLenActual As Integer) As String
Dim i As Integer
Dim s As String = String.Empty
For i = 0 To intBufferLenActual - 1
s &= Chr(Marshal.ReadByte(p, i))
Next
ConvertBufferToString = s
End Function
Private Sub AppendToLog(ByVal pRowChange As IReplRowChange, ByRef s As
String, ByVal inMsg As String)
s = s & ";" & inMsg
If Len(s) < 50 Then Call pRowChange.LogError(REPOLEAllChanges, s)
End Sub
End Class
u rock man!
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Douglas Arterburn" <darterburn@.precisdev.com> wrote in message
news:uzhwyd7iFHA.3656@.TK2MSFTNGP09.phx.gbl...
> Someone posted the question "Can anyone point me towards a source code
> listing for a working replication custom resolver written in .Net?" Here
> is an example that I have written.
> Custom resolvers are created by adding a reference to the Microsoft SQL
> Replication Conflict Resolver Library, replrec.dll. Unfortunately, the
> .NET type library importer incorrectly defines the buffer parameter of
> methods GetSourceColumnValue, GetDestinationColumnValue, and SetColumn to
> be the address of an Object. For COM interfaces, which is what
> replrec.dll is supposed to be, that implies a COM-VARIANT parameter
> passing mechanism, but this is not what Replrec passes back. Replrec is
> simply passing back the address of a buffer containing the column value
> which you have to decode.
> So the solution involves correcting the method definitions so that a
> buffer address can be passed and using the .NET Marshal routines to create
> the buffer and move bytes out of the buffer.
> Here are the steps involved, followed by a code example that resolves
> conflicts by using the column values from the row with the latest date in
> user defined column ModifyDate.
> 1. Open a Visual Studio .NET 2003 Command Prompt
> 2. tlbimp "c:\Program Files\Microsoft SQL Server\80\COM\replrec.dll"
> /OUT:SQLResolver_import.dll
> 3. ildasm "SQLResolver_import.dll" /OUT=SQLResolver.il
> 4. Change line "[out] object& marshal( struct) pvBuffer" for the methods
> GetSourceColumnValue, GetDestinationColumnValue, and SetColumn to "[out]
> int32 pvBuffer"
> 5. ilasm SQLResolver.il /OUT=SQLResolver.dll /dll
> 6. Create a new .NET Windows Control Library project
> 7. Remove the wizard generated control
> 8. Use "Add New Item..." to add a new COM class
> 9. Add reference to SQLResolver.dll created in step #5
> Imports System.Text
> Imports SQLResolver
> Imports System.Runtime.InteropServices
> Imports System.Runtime.InteropServices.MarshalAsAttribute
> Imports SQLResolver.REPOLE_CHANGE_TYPE
> Imports SQLResolver.REPOLE_COLSTATUS_TYPE
> <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
> Public Class ComClass1
> Implements SQLResolver.IVBCustomResolver
> Private Const MAX_BUFFER_SIZE As Integer = 1048576
> Private Const MAX_NAME_LENGTH As Integer = 128
> #Region "COM GUIDs"
> ' These GUIDs provide the COM identity for this class
> ' and its COM interfaces. If you change them, existing
> ' clients will no longer be able to access the class.
> Public Const ClassId As String = "825818F7-3531-4524-8B07-72343EFDC8AB"
> Public Const InterfaceId As String =
> "CECFBB8F-584F-4733-9373-B69AFA6F117F"
> Public Const EventsId As String =
> "5D55BA40-A438-4FD4-BA8B-05095DC89948"
> #End Region
> ' A creatable COM class must have a Public Sub New()
> ' with no parameters, otherwise, the class will not be
> ' registered in the COM registry and cannot be created
> ' via CreateObject.
> Public Sub New()
> MyBase.New()
> End Sub
> Public Sub GetHandledStates(ByRef ResolverBm As Integer) Implements
> IVBCustomResolver.GetHandledStates
> ResolverBm = REPOLEUpdateConflicts
> End Sub
> Public Sub Reconcile(ByVal pRowChange As IReplRowChange, ByVal dwFlags As
> Integer, ByVal pvReserved As IReplRowChange) Implements
> IVBCustomResolver.Reconcile
> Dim cntColumns As Integer
> Dim intColumn As Integer
> Dim strColumnName As String
> Dim strLogMessage As String
> Dim WinningData As Object
> Dim blnSourceIsWinner As Boolean
> Dim ColStatus As SQLResolver.REPOLE_COLSTATUS_TYPE
> Dim intBufferLenActual As Integer
> Dim intBufferLen As Integer
> Dim strDestinationDateTime As String
> Dim strSourceDateTime As String
> Dim strDestinationUser As String
> Dim strSourceUser As String
> Dim myBuffer As IntPtr = Marshal.AllocHGlobal(MAX_BUFFER_SIZE)
> Dim strMsg As String
> 'If Not Debugger.IsAttached Then
> ' Debugger.Launch()
> 'Else
> ' Debugger.Break()
> 'End If
> Call pRowChange.GetNumColumns(cntColumns)
> For intColumn = 1 To cntColumns
> strColumnName = " ".PadRight(MAX_NAME_LENGTH)
> ' strColumnName.PadRight(OSQL_SYSNAME_SET, Chr(vbNull))
> Call pRowChange.GetColumnName(intColumn, strColumnName,
> MAX_NAME_LENGTH)
> ' strColumnName.TrimEnd(Chr(vbNull))
> strColumnName = strColumnName.TrimEnd()
> If (String.Compare(strColumnName, "ModifyDate", True) = 0) Then
> pRowChange.GetDestinationColumnValue(intColumn, myBuffer.ToInt32,
> MAX_BUFFER_SIZE, intBufferLenActual)
> strDestinationDateTime = ConvertBufferToDateString(myBuffer)
> pRowChange.GetSourceColumnValue(intColumn, myBuffer.ToInt32,
> MAX_BUFFER_SIZE, intBufferLenActual)
> strSourceDateTime = ConvertBufferToDateString(myBuffer)
> If strSourceDateTime > strDestinationDateTime Then
> blnSourceIsWinner = True
> Else
> blnSourceIsWinner = False
> End If
> End If
> If (String.Compare(strColumnName, "ModifyUser", True) = 0) Then
> pRowChange.GetDestinationColumnValue(intColumn, myBuffer.ToInt32,
> MAX_BUFFER_SIZE, intBufferLenActual)
> strDestinationUser = ConvertBufferToString(myBuffer, intBufferLenActual)
> pRowChange.GetSourceColumnValue(intColumn, myBuffer.ToInt32,
> MAX_BUFFER_SIZE, intBufferLenActual)
> strSourceUser = ConvertBufferToString(myBuffer, intBufferLenActual)
> End If
> Next intColumn
> For intColumn = 1 To cntColumns
> 'Get the column status of each column
> pRowChange.GetColumnStatus(intColumn, ColStatus)
> ' If the column has been updated at both the Publisher and Subscriber
> If (ColStatus = REPOLEColumn_UpdatedWithConflict) Then
> If blnSourceIsWinner Then
> pRowChange.CopyColumnFromSource(intColumn)
> End If
> ' For columns that have been updated without any changes, copy column
> values from source
> ElseIf (ColStatus = REPOLEColumn_UpdatedNoConflict) Then
> pRowChange.CopyColumnFromSource(intColumn)
> ' For columns that have not been updated - do nothing.
> ElseIf (ColStatus = REPOLEColumn_NotUpdated) Then
> End If
> Next intColumn
> ' Log conflict and call the UpdateRow method to commit all the column
> value changes.
> '
> If strDestinationDateTime.Length > 0 And strDestinationUser.Length > 0
> Then
> If blnSourceIsWinner Then
> strMsg = "Losing update(s) made by " & strDestinationUser
> Else
> strMsg = "Losing update(s) made by " & strSourceUser
> End If
> End If
> pRowChange.LogConflict(REPOLE_BOOL.REPOLEBool_TRUE ,
> REPOLE_CONFLICT_TYPE.REPOLEConflict_ColumnUpdateCo nflict,
> REPOLE_BOOL.REPOLEBool_FALSE, strMsg, REPOLE_BOOL.REPOLEBool_FALSE)
> Call pRowChange.UpdateRow()
> Marshal.FreeHGlobal(myBuffer)
>
> End Sub
> Private Function ConvertBufferToDateString(ByVal p As IntPtr) As String
> Dim s As String = String.Empty
> Dim i(7) As Short
> Dim j As Integer
> Marshal.Copy(p, i, 0, i.Length)
> s = i(0).ToString '4 digit Year
> For j = 1 To i.GetUpperBound(0)
> s &= i(j).ToString.PadLeft(2, "0"c)
> Next
> ConvertBufferToDateString = s
> End Function
> Private Function ConvertBufferToString(ByVal p As IntPtr, ByVal
> intBufferLenActual As Integer) As String
> Dim i As Integer
> Dim s As String = String.Empty
> For i = 0 To intBufferLenActual - 1
> s &= Chr(Marshal.ReadByte(p, i))
> Next
> ConvertBufferToString = s
> End Function
> Private Sub AppendToLog(ByVal pRowChange As IReplRowChange, ByRef s As
> String, ByVal inMsg As String)
> s = s & ";" & inMsg
> If Len(s) < 50 Then Call pRowChange.LogError(REPOLEAllChanges, s)
> End Sub
> End Class
>

Creating a custom Delivery Extension (File Share)

I would like to create a custom delivery extension wherby I take the filename of my report and then append a date time stamp to it. While I have some knowledge of RS I have little practical programming expierience.

I have little fear of learning something new, but I like to take known good working model, understand why / how it works and then apply that to my situation.

Are there any "Dummies" type of tutorials out there to get me started down this road?

Thanks for reading

hi , you can use this code .

public bool Deliver(Notification notification)
{
string reportName = notification.Report.Name;
}