Click here to Skip to main content
16,005,734 members
Home / Discussions / C#
   

C#

 
AnswerRe: display contents in liswtbox Pin
laserbaronen9-Nov-07 3:07
laserbaronen9-Nov-07 3:07 
AnswerRe: display contents in liswtbox Pin
Luc Pattyn9-Nov-07 3:53
sitebuilderLuc Pattyn9-Nov-07 3:53 
QuestionRegex problem Pin
laserbaronen9-Nov-07 2:57
laserbaronen9-Nov-07 2:57 
AnswerRe: Regex problem Pin
laserbaronen9-Nov-07 4:28
laserbaronen9-Nov-07 4:28 
QuestionSet checked state on all selected rows in datagridview Pin
hakonvik9-Nov-07 2:53
hakonvik9-Nov-07 2:53 
AnswerRe: Set checked state on all selected rows in datagridview Pin
Nathan Holt at EMOM9-Nov-07 5:30
Nathan Holt at EMOM9-Nov-07 5:30 
GeneralRe: Set checked state on all selected rows in datagridview Pin
hakonvik9-Nov-07 10:07
hakonvik9-Nov-07 10:07 
QuestionSqlNotification Problem. Pin
hdv2129-Nov-07 1:46
hdv2129-Nov-07 1:46 
hi i create a queue and service in my sql server 2005 by this code :

create queue myNotificationQueue
create service myService on queue myNotificationQueue

in my csharp code i wrote this code : (i copy this instance from msdn website)
class Program
{
string connstring = null;
SqlConnection conn = null;
SqlDataReader rdr = null;

static void Main(string[] args)
{
Program c = new Program();
c.connstring = @"Data Source=MYLAPTOP\SQLLAPTOP;Initial Catalog=pubs;Persist Security Info=True;User ID=sa;Password=1";
c.conn = new SqlConnection(c.connstring);
c.DoWork();
Console.ReadLine();
}

private void DoWork()
{
conn.Open();
rdr = GetJobs(2);
if (rdr != null)
{
rdr.Close();
WaitForChanges();
}
conn.Dispose();
}

public SqlDataReader GetJobs(int JobId)
{
using (SqlCommand cmd = new SqlCommand("Select job_id, job_desc from dbo. jobs where job_id = @id", conn))
{
try
{
cmd.Parameters.AddWithValue("@id", JobId);
SqlNotificationRequest not = new SqlNotificationRequest();
not.ID = new Guid(); // error occured

// this must be a service named MyService in the pubs database
// associated with a queue called notificationqueue (see below)
// service must go by QueryNotifications contract
not.Service = "myService"; // error occured
not.Timeout = 0;

// hook up the notification request
cmd.Notification = not;
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return rdr;
}
}

public void WaitForChanges()
{
// wait for notification to appear on the queue
// then read it yourself
using (SqlCommand cmd = new SqlCommand("WAITFOR (Receive convert(xml,message_body) from notificationqueue)", conn))
{
object o = cmd.ExecuteScalar();

// process the notification message however you like
Console.WriteLine(o);
}
}
}

but when i compile it, two following errors shown me :
System.Data.Sql.SqlNotificationRequest' does not contain a definition for 'ID'
System.Data.Sql.SqlNotificationRequest' does not contain a definition for 'Service'

How to solve my problem ?
thanks
AnswerRe: SqlNotification Problem. Pin
TJoe9-Nov-07 2:06
TJoe9-Nov-07 2:06 
GeneralRe: SqlNotification Problem. Pin
hdv2129-Nov-07 4:19
hdv2129-Nov-07 4:19 
QuestionLoad an image with directx Pin
QzRz9-Nov-07 1:27
QzRz9-Nov-07 1:27 
QuestionThousands of remote message queues - possible? Pin
jenspa8-Nov-07 23:46
jenspa8-Nov-07 23:46 
AnswerRe: Thousands of remote message queues - possible? Pin
jenspa9-Nov-07 1:16
jenspa9-Nov-07 1:16 
QuestionInteresting Project? Pin
daviiie8-Nov-07 23:37
daviiie8-Nov-07 23:37 
AnswerRe: Interesting Project? Pin
Colin Angus Mackay9-Nov-07 0:43
Colin Angus Mackay9-Nov-07 0:43 
GeneralRe: Interesting Project? Pin
daviiie9-Nov-07 1:20
daviiie9-Nov-07 1:20 
Questiongridviewer Pin
merwa8-Nov-07 23:31
merwa8-Nov-07 23:31 
QuestionSimulate mouseclick?? Pin
jafingi8-Nov-07 23:03
jafingi8-Nov-07 23:03 
AnswerRe: Simulate mouseclick?? [modified] Pin
Rajasekharan Vengalil9-Nov-07 0:38
Rajasekharan Vengalil9-Nov-07 0:38 
GeneralRe: Simulate mouseclick?? Pin
jafingi27-Nov-07 5:13
jafingi27-Nov-07 5:13 
QuestionGeneral Concern Pin
kingletas8-Nov-07 22:50
kingletas8-Nov-07 22:50 
AnswerRe: General Concern Pin
Adeel Chaudhry11-Nov-07 18:59
Adeel Chaudhry11-Nov-07 18:59 
Questionclock( ) function in C# Pin
baerten8-Nov-07 22:31
baerten8-Nov-07 22:31 
AnswerRe: clock( ) function in C# Pin
Giorgi Dalakishvili8-Nov-07 22:46
mentorGiorgi Dalakishvili8-Nov-07 22:46 
GeneralRe: clock( ) function in C# Pin
baerten8-Nov-07 23:28
baerten8-Nov-07 23:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.