473,503 Members | 10,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET Dataset Table Properties

Here is the PowerShell script I've been working on (.NET question is at the bottom):

### setup SQL connection
$conn = new-object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "server=*****;database=****;UID=*****;PWD=**** *"

### setup SQL command
$cmd = new-object System.Data.SqlClient.SqlCommand

### Get SQL commands from text file
$cmd.CommandText = get-content h:\scripts\vistar_sql.txt

$cmd.Connection = $conn

###setup SQL adapter to fill in info
$adapter = new-object System.Data.SqlClient.SqlDataAdapter
$adapter.SelectCommand = $cmd

### Create dataset object (.NET Class representing an in-memory cache of data)
$ds = new-object System.Data.DataSet

### fill object with SQL data
$nRecs = $adapter.Fill($ds)
### output to host how many contacts in vistar.
Write-Host ($nRecs.ToString() + " Vistar Contacts retrieved.")

###Close the SQL connection
$conn.close()

###add column to .NET dataset table
$full_name = new-object "System.Data.DataColumn" ("full_name", [string])
$ds.Tables[0].Columns.add($full_name)


$email = @($ds.Tables[0] | foreach { $_.email.trimend() }) | sort

$mso_email = @(get-mailcontact -Organizationalunit "mso" | foreach {$_.externalEmailAddress} | foreach {$_.smtpaddress}) | sort
write-host ($mso_email.count.tostring() + " Total contacts in MSO Exchange OU")
### stores email addresses in array $email
$email = @($ds.Tables[0] | foreach { $_.email.trimend() }) | sort

$diff = diff -syncwindow 525 $email $mso_email

$vistar_only = $diff | % { if ($_.SideIndicator -match '<=') {$_.InputObject}}
write-host ($vistar_only.count.tostring() + " Contacts only in Vistar")
$mso_only = $diff | % { if ($_.SideIndicator -match '=>') {$_.InputObject}}
write-host ($mso_only.count.tostring() + " Contacts only in MSO Exchange OU")

$mso_only = $diff | % { if ($_.SideIndicator -match '=>') {$_.InputObject}} | remove-mailcontact
The script is going to be used to keep a SQL database in Sync with Exchange 2007 contacts, so that external people can in included in e-mail distribution lists.

The current issue that I have is that the properties of the Exchange mailcontact object includes the "name" property which is in the lastname, firstname format. The properties of the .NET dataset table include a lastname property and a firstname property. So I figured out how to add a new property to that .NET object / table, but I can't figure out how to fill that column / rows. If you could take a look at the code and LMK what you think, it would be appreciated.

Thanks,

-Nick
Aug 4 '08 #1
0 1159

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1785
by: Marty | last post by:
Hi, Ok I use the OLEDBConnector and dataset to retrieve data from my Access DB. I have a problem to read/parse the dataset and I would like to know if I am using the right object to reach my...
8
2242
by: drg | last post by:
I have a DataSet with a DateTime field. I am using an EventRow r, to update it with values from a TextBox in a DataGrid. Suppose a DataGrid in edit mode had a field with value: 7/7/2005. Then the...
2
1675
by: ringo | last post by:
I've come accross an interesting problem populating an asp.net datagrid. I am trying to bind XML data to a datagrid as I've done in countless other applications, the only difference this time being...
4
4189
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
4
1425
by: Robert Bravery | last post by:
Hi All, I'm New to VS.net. Trying to figure out this new dataset thingy. Ok so I add a dataadapter with all the correct properties for a table. Then generate the dataset. Now open the dataset and...
2
3266
by: Bob | last post by:
I have a CreatedOn field , datetime, which has GetDate() as the default value in SQL server 2000 table. When I create a new record in the table itself in enterprise manager, the field gets...
3
3207
by: JimmyKoolPantz | last post by:
I have an ongoing problem that I can not seem to figure out. The problem is everytime I bind data to a dataset or datatable where the data source does not have a "header row" the first record in...
3
6669
by: shapper | last post by:
Hello, I have a stored procedures as follows: SELECT a.ArticleID, a.Title, a.Content, c.CommentId, c.Title, c.Comment FROM Articles a INNER JOIN Comments c ON a.ArticleID = c.CommentID...
1
2577
by: jc | last post by:
RE: Why use a CollectionBase class here vs dataset or dataview? I'm looking at some vb.net 2005 code that was generated from a homegrown Codesmith Template that generate all of the retreival and...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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

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