|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_denali_newmail_object_cdonts_library_.asp?frame=true
that should help
Will
|
|
|
|
|
here is my sp. For some reason it won't attache file. Any idea why?
CREATE PROCEDURE CDO_SendMail_test(
@From varchar(255) = 's@yahoo.com',
@To varchar(255),
@Cc varchar(255) = '',
@Bcc varchar(255) = '',
@Subject varchar(255),
@MessageFormat int = 0, -- default to HTML, 1 = text, 0 = html
@Message varchar(8000),
@Priority int = 2,
@AttachFile varchar(8000) -- default to high, 1 = normal, 0 = low
)
AS
DECLARE @CDO int, @OLEResult int, @Out int
--Create CDONTS.NewMail object
EXECUTE @OLEResult = sp_OACreate 'CDONTS.NewMail', @CDO OUT
IF @OLEResult <> 0 PRINT 'CDONTS.NewMail'
--Set CDONTS.NewMail properties
execute @OLEResult = sp_OASetProperty @CDO, 'From', @From
execute @OLEResult = sp_OASetProperty @CDO, 'To', @To
execute @OLEResult = sp_OASetProperty @CDO, 'Cc', @Cc
execute @OLEResult = sp_OASetProperty @CDO, 'Bcc', @Bcc
execute @OLEResult = sp_OASetProperty @CDO, 'Subject', @Subject
execute @OLEResult = sp_OASetProperty @CDO, 'BodyFormat', @MessageFormat
execute @OLEResult = sp_OASetProperty @CDO, 'Body', @Message
execute @OLEResult = sp_OASetProperty @CDO, 'Importance', @Priority
execute @OLEResult = sp_OAMethod @CDO, 'AttachFile', @AttachFile--'' [, ''] [, ]
--Call Send method of the object
execute @OLEResult = sp_OAMethod @CDO, 'Send', Null
IF @OLEResult <> 0 PRINT 'Send'
--Destroy CDO
EXECUTE @OLEResult = sp_OADestroy @CDO
return @OLEResult
GO
exec CDO_SendMail_test
@From = 'yyr@yahoo.com',
@To = 'tt@chickering.com',
@Cc = '',
@Bcc = '',
@Subject = 'test',
@MessageFormat = 0,
@Message = '',
@AttachFile ='\\bsar\test.txt'
|
|
|
|
|
I have a search page in ASP that has three fields users can search under but can also leave blank if they want to. My problem is I want to have a SELECT statment that can do wildcards but I am not sure if thats possible or if I just cant get it to work. For instance here is an example of what I would want.
SELECT * FROM rbcheckout WHERE TitleName='*' AND RSNumber ='*' AND Platform ='Playstation 2';
While a valid query it doesn't work cause it should bring up every record that has Platform as Playstation 2. Doning some searching on the net I saw that % was also a wildcard so it would be like
SELECT * FROM rbcheckout WHERE TitleName='%' AND RSNumber ='%' AND Platform ='Playstation 2';
But that doesnt work either. Anyone know if I am going about this wrong or what?
|
|
|
|
|
You need to use the LIKE operator when doing wildcard expressions:
SELECT *
FROM rbcheckout
WHERE TitleName LIKE '%' AND
RSNumber LIKE '%' AND
Platform = 'Playstation 2';
- Mike
|
|
|
|
|
Thanks!
|
|
|
|
|
I might suggest to remove the columns in your whre with the wildcard "%". instead, only the where clause with criteria as "Station 2" will be there. Try it and it will give you the same result.
/vb;PUser
|
|
|
|
|
|
Timeout expired
This is an error my application is getting at any sporadic time. My application is written in VC++ and uses ADO to make a permanent connection to SQL server. The application usually gets this error after two or three days but sometimes it may get this error just after two or three hours. Our tables are very simple. We use stored procedures and each stored procedure hardly takes 20 milliseconds to execute. But after some sporadic time when application tries to execute a stored procedure, it gets "timeout expired" error.
Any suggestion ??
Imtiaz
|
|
|
|
|
This could be a lock timeout. Lock timeouts might occur if you begin an explicit transaction but never commit it or roll it back. The default transaction isolation level is READ COMMITTED, where different sessions can only see data committed by other sessions, not data that hasn't yet been committed.
If you have a situation where connection A has updated a row but not committed the change, and connection B tries to read it, B will block waiting for A to commit before it can read. If you have a situation where B has a recordset open and hasn't read all of it, and A's update would affect that recordset, A will block until B closes its recordset. This assumes server-side cursors - with client-side cursors and forward-only, read-only recordsets, SQL Server just throws the whole resultset at B.
ADO normally uses connection pooling, so there's rarely much cost to closing and reopening a connection if you've used it recently. If it isn't used, ADO will close the connection fully, saving server resources.
Check your transactions and your connection logic.
|
|
|
|
|
Hello,
I am trying to write a procedure that does the following. I currently have the user enter data in a textbox that populates a cbo. When they select data in the cbo it populates a listbox. I want the user to be able to take the items checked in a listbox and rename them. The data originated from what the user put in(batchno). So I want to be able to take the selected items in the textbox and rename a new "batchno" but leave the ones that were not selected. Thank you for your help.
Michael
|
|
|
|
|
I'm having trouble setting a table with 2 primary keys. I get an error saying Primary Key already exists. I'm using ADOX with C++.
Thanks
|
|
|
|
|
Anthony9887 wrote:
2 primary keys
Reading your post, I'm wondering if you did as well.
'Primary' implies one, so how can you have two?
I think what you might be confusing here are indexes and keys. You can define many indexes for a table, but you can only define one primary key.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"And when you need to hire a programmer to do mostly VB programming, it's not good enough to hire a VB programmer, because they will get completely stuck in tar every time the VB abstraction leaks." Joel on Software Nov 11, 2002.
|
|
|
|
|
Further to Chris' reply, what you're probably really trying to do is define a primary key that consists of multiple columns. Which is perfectly allowed and acceptable.
#include <beer.h>
|
|
|
|
|
i made an app that uses MDI enviorment.
i want to be able to access the same DataSet from all of the child forms.
how can i do that?
-- Directly From Zion --
------ Haimon15 ------
|
|
|
|
|
This is not really an SQL/ADO/ADO.NET question, but anyway...
There are a couple of approaches:
1. Declare your DataSet as a public in your MDI parent. In your child windows you use the this.MdiParent property to access your parent window.
Sample code:
<br />
public class MyChildForm : System.Windows.Forms.Form<br />
{<br />
private DataSet myDataset<br />
{<br />
get<br />
{<br />
MyParentForm mdiParent = this.MdiParent;<br />
return mdiParent.myDataset;<br />
}<br />
}<br />
}<br />
<br />
public class MyParentForm : System.Windows.Forms.Form<br />
{<br />
private DataSet myDataset;<br />
}
Now, in your MdiChild you access your dataset by using the MyDataSet property.
You can now insert the abstract keyword in the definition of MyChildForm, and make all your actual mdi child forms inherit the MyChildForm abstract class instead of System.Windows.Forms.Form. Then the MyDataSet property will be available withot anymore work...
2. You could create a class with a static DataSet member... (Or a singleton class)
Then that dataset would be available all over the application...
|
|
|
|
|
hi all
I have one store procedure and I want that how to get parameters in this store and put to table with SQL command
ex : myStore(@param1, @param2,@param3...)
use sql and return name column
index name
1 @param1
2 @param2
3 @param3
... .....
somebodys can help me, please.
thanks !!!
nhoc ti`
|
|
|
|
|
D,
If I am understanding you correctly you trying to do a basic insert stored proc.
CREATE PROCEDURE dbo.insertdata
(
@param1 varchar(50),
@param2 varchar(50),
@param3 varchar(50),
)
AS
BEGIN
INSERT INTO databasname
VALUES (@param1, @param2, @param3)
END
GO
What application are you using to insert the data? ASP,ASP.NET or Windows Form!
HTH
Tony
|
|
|
|
|
oh no, I want GET ALL PARAMETER NAME in this store procedure
|
|
|
|
|
You can use sp_procedure_params_rowset 'your_procedurename_here' .
It returns a rowset containing the names, types and other info on the parameters that you procedure takes.
This is the SP that is used by MS in their Data Access Application Blocks (DAAB) for .NET and in earlier versions of ADO.
|
|
|
|
|
|
I have these fields that I need to search in the database.
Name 50, Description 255, Code 8000, Notes 2000
for a user defined value.
Does anyone know a site that has good info on doing complex
searches in a database. Preferably how to build the Query string.
Thank You
Bo Hunter
|
|
|
|
|
|
You might find the LIKE operator useful for picking up specific terms:
<br />
select * from Table where Description LIKE '% term %'<br />
will find anything with " term " in (I've added spaces to pick up the complete word)
--
Ian Darling
|
|
|
|
|
Adding spaces can help to isolate the complete word but it won't (for example) pick up the word "sentence" in this sentence.
|
|
|
|
|
True, but I thought I made that reasonably clear - the code was illustrative, not complete. You could modify the LIKE clause to handle those cases.
--
Ian Darling
|
|
|
|
|