|
hi all ,i have 2 windows applications in c# connected with sql2005 database at the same time .these 2 windows applications insert a data in the database .i want that when one of these applications insert a row in database ,sqlserver2005 send a message or anything to the other application to inform it that a new row is inserted .it means that sql2005 send message to application.how i can do this?
Essampro
|
|
|
|
|
Look at sql server broker notification, that should do it.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
think first in a LOCK protection (if you don´t have one).
i don´t know really how can i help you but, i suggest you to run/trigger a procedure to show the changed data since you logged out(meaning this user), i think is more important that the "on time update" info.
you can also create a log table, will be lot of aid there, to get who changed what and when!!!
do you need that kind of on time info, something like stock market info?
listen, you can make that on time info, or you can trigger a procedure after a short period of time, say 5min.
if i was you i would create a procedure to get the changed data since my last login/out and a procedure to get that on time info triggered each 5 min or like you said.
good luck
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
You don't need to do all this, with SQL Server 2005 there is a thing called Broker Service Notification which does it for you - well almost - you do have to write a bit of code yourself
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Broker Service Notification? what the f*** is that?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
It was introduced in SQL Server 2005. Here is a link to the definitive book [^]
and here is a link to the msdn details [^]
nelsonpaixao wrote: Broker Service Notification? what the f*** is that
As I frequently tell posters, try Google!
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thanks, i will see what that for and if is usefull for me
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
what is the difference between ado.net and ado.net db
What is the difference between trigger and Stored Procedure
modified on Sunday, September 21, 2008 2:15 PM
|
|
|
|
|
Try googling. You'll find plenty of explanation there.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
arunmca.r wrote: what is the difference between ado.net and ado.net db
What is the difference between trigger and Stored Procedure
And why should anyone else do your homework?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi guys
I want to know how to display a picture stored in an attachment field in an Access 2007 database in a Visual C# picture box or more generally exporting a file from an attachment field in access 2007, I searched a lot but couldn't find, Please help.
Thanks.
|
|
|
|
|
Don't cross post.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I need a solution.
Assmbler
|
|
|
|
|
Cross posting to demand a solution from people isn't the ideal approach, either. Now, that aside, what have you tried doing with your problem so far? What is the field type you are using in Access to store the attachments? Are the attachments of one type, or is it various types of file formats?
People will need a little more detail if you expect any real help.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The field type is Access2007 Attachment data type,the files stored in those fields are 90% jpg images plus some png and bmp images, When I try to get the contents of the field in c# it only returns their file name, I'm sure that there must be a way to get files from db. VBA has LoadFromFile and SaveToFile functions for working with attachments, but We need the equvalent ADO functions.
Assmbler
|
|
|
|
|
Could you show code example why you are just getting the filename in return?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for the reply.
strCmd = "SELECT FLAG FROM SongsFlagsContinents WHERE SECT='" + CountryName + "'";
cmd = new OleDbCommand(strCmd, Main.Connection);
cmd.Connection.Open();
rdr = cmd.ExecuteReader();
rdr.Read();
MessageBox.Show(rdr["FLAG"].ToString());
cmd.Connection.Close();
where FLAG column is an attachment column with image(s) attached.
|
|
|
|
|
Hi!
I am experiencing the following error and I couldn't find a solution. UserType field doesn't allow null values in the table as it has defined so. Before I INSERT the value for the field I get 1 as a value ofor the USERTYPE field. The data types are identical in both table and in the stored procedure.
I am using VS2008 and with SQLEXPRESS 2008.
However It pops up the following error message. If you know the solution, please let me know.
<br />
<br />
Cannot insert the value NULL into column 'UserType', table 'HolidayDB.dbo.Administration'; column does not allow nulls. INSERT fails. The statement has been terminated.<br />
<br />
'USER TYPE DEFINITION IS AS BELOW<br />
<br />
SetUserType = New SqlParameter()<br />
SetUserType.ParameterName = "@GetUserType"<br />
SetUserType.SqlDbType = SqlDbType.BigInt<br />
SetUserType.Size = 8<br />
SetUserType.IsNullable = False<br />
SetUserType.Direction = ParameterDirection.Input<br />
SetUserType.Value = CType(GetUserType.SelectedValue, Object)<br />
MYCOMMAND.Parameters.Add(SetUserType)<br />
<br />
<br />
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Could you post the SP?
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
Thanks for responding. Here is my stored procedure but none of stored procedures are functioning in SQL server. I have no idea why. I am able to insert a data into tables by querying but when I try to invoke a stored procedure I always get an error message. For the following storedprocedure I get "@GetUserType is not supplied " error message even I supply the data.
Thank you.
ALTER PROCEDURE dbo.StoredProcedure3
(
@GetUserType bigint,
@GetAccountStatus bit,
@GetTitle nchar(10),
@GetFirstName nvarchar(50),
@GetMiddleInitial nchar(2),
@GetLastName nvarchar(50),
@GetEmailAddress nvarchar(125),
)
AS
INSERT INTO Customer
VALUES (
@GetUserType,
@GetAccountStatus,
@GetTitle,
@GetFirstName,
@GetMiddleInitial,
@GetLastName,
@GetEmailAddress,
EXEC StoredProcedure3
RETURN
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hmm...Despite some sintax errors I could notice in the procedure (maybe from when you paste in here), I think you're problem could be the way the procedure is executing the insert.
When you do:
INSERT INTO Customer (Field1,Field2) VALUES (Value1,Value2);
You are addressing the values (Value1,Value2) in the corresponding order as the appear in the field list (Field1,Field2), but as you did:
INSERT INTO Customer VALUES (Value1,Value2);
You are putting the values in the order the fields appear in the table, so if the table has one more column or a column in the wrong order, you could get unwanted results.
Try using the first form of insert. If it did not work, post the table structure to see if we can help you.
Regards
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
Thanks Cio!
The INSERT syntax I have used is correct in SQL 2008. The syntax you have suggested to me for use is causing an error when I try to save it as a stored procedure. I am experiencing the same problem for all the other stored procedures in SQL SERVER. I am newbie to SQL and I have no idea what is causing the problem. When I use query, it is working fine but when I try to invoke a storedprocedure, it is causing an error.
The table structure is as show below.
COLUMN NAME DATA TYPE ALLOW NULLS
(PK)CustomerNumber bigint False (IDENTITY COLUMN)
(FK)UserType bigint False
AccountStatus bit False
FirstName nvarchar(50) False
MiddleInitial nchar(2) True
LastName nvarchar(50) False
EmailAddress nvarchar(125) False
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Sunday, September 21, 2008 5:40 AM
|
|
|
|
|
Hi,
Basic cause for this is that for some reason you are trying to insert NULL to GetUserType. Reasons in your case could be:
- parameter SetUserType has a value of NULL when call to sp is made (but I understood you have checked this)
- when using INSERT syntax where you don't define columns for the values, you can get mixed in column order as Caio pointed out. Modifying the insert statement to following may help. Also notice GetTitle parameter. Didn't find any corresponding field in your table based on your description
INSERT INTO Customer
(
UserType,
AccountStatus,
FirstName,
MiddleInitial,
LastName,
EmailAddress )
VALUES (
@GetUserType,
@GetAccountStatus,
@GetTitle, <-------- Where is this parameter going
@GetFirstName,
@GetMiddleInitial,
@GetLastName,
@GetEmailAddress)
- also I noticed the call to StoredProcedure3 inside the values portion. Is this intended
@GetEmailAddress,
EXEC StoredProcedure3 <------
RETURN
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Thanks a lot!
The problem has been solved. The EXEC statement was causing the problem. I removed it and then it worked.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You're welcome
Mika
The need to optimize rises from a bad design
|
|
|
|