|
I did not mean creating one table per end-user class. In my example, the CLASSES table will hold information for all the instances of the AClass class. So essentially, you would be dealing with only a handful of tables - one for all the end-user classes, one for all the end-user structs, one for all the end-user unions, etc.
Damodar Periwal
Software Tree, Inc.
Simplify Data Integration
http://www.softwaretree.com
|
|
|
|
|
Hi,
I need to implement a function that sends emails on a perticular date and time. The date and time is specified by the user when he posts a new event into a on-line calendar. The user should be allowed to decide when an event notification email will be sent to a group of people.
The database used for the project is SQL server. I learn about SQL server job scheduler can do it. But I don't know how to add a job into SQL server job list when a record is submited into database from web form.
Is there anybody having any advices?
Thanks in advance!
|
|
|
|
|
firstly add the time and date from web form to database table for each user.
then add only one job that run after each minute in Management-->SQL Jobs.
Now what this job will be done ?.
It will first check the date and time of users and then it will send mail using following code if the user is reach to its exact time.
Code you can view from following link:
http://www.vbforums.com/archive/index.php/t-280616.html
and read about how to add a new SQL server job in database in detail.
Qaisar Mehmood Mughal
...............................................................................
May Allah gave u success in all fields of life. (Aameen)
...............................................................................
Software Engineer
ISF - Islamabad Software Factory
3rd Floor, Software Technology Park
Constitution Avenue, Islamabad 44000, Pakistan
www.isf.com.pk
qaisar@isf.com.pk , qmmughal@gmail.com
Phone: +92 (51) 2825387 : 0321-5226623
|
|
|
|
|
Thank you very much, Qaisar!
It definitely will help a lot.
|
|
|
|
|
Hello everyone,
I have a rather large query that returns some fields, including a date field. Some dates are in the future, some are in the past, and some of the results are null. I need to find a way to arrange them so the nearest dates to today are displayed, then the ones further away, then the older ones, then the nulls.
Example: given that getDate() = Jan 23 2006 2:41PM
------------
1 Jan 30 2006 3:00PM
2 Jan 20 2006 1:14PM
3 NULL
4 Dec 31 2006 11:00AM
5 Jan 24 2006 7:00PM
6 NULL
I want the result set to be arranged like so:
-----------
1 Jan 24 2006 7:00PM
2 Jan 30 2006 3:00PM
3 Jan 20 2006 1:14PM
4 Dec 31 2006 11:00AM
5 NULL
6 NULL
As perviously mentioned the query is huge so I'd like to avoid using a union if at all possible, just to reduce clutter. But if it needs to be done, it needs to be done.
Any ideas? Thanks in advance!
-------------------
abort, retry, fail?
|
|
|
|
|
jszpila wrote: As perviously mentioned the query is huge so I'd like to avoid using a union if at all possible, just to reduce clutter
Yes, it can be done without UNIONs
SELECT dateColumn,
ABS(DATEDIFF(minute, dateColumn, @distanceFromThisTime)) AS TimeDifference,
CASE WHEN dateColumn IS NULL THEN 0 ELSE 1 END AS Nothing
FROM myTable
ORDER BY CASE WHEN dateColumn IS NULL THEN 0 ELSE 1 END DESC,
ABS(DATEDIFF(minute, dateColumn, @distanceFromThisTime)) ASC
In the above code:
dateColumn is the column that contains the date information.
@distanceFromThisTime is a datetime variable that contains the time that the query is centred on, probably getdate() from your description.
The ORDER BY clause first of all sinks the NULL s to the bottom, then it orders the remaining stuff in ascending order.
Finally, you can obviously ditch the TimeDifference and Nothing columns, I put them in to illustrate what values might be returned if you wanted to try this code in query analyzer first.
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
-- modified at 17:48 Monday 23rd January, 2006
|
|
|
|
|
Thanks! It's definitely a step in the right direction, but it's kinda goofing the order of the dates. It has successfully pushed all the nulls to the bottom, though.
My results along these lines (I'm doing some formatting in the SQL - I'm doing the formatting independently with an alias so I don't think it would be messing it up):
01/26/06
01/18/06
01/31/06
01/13/06
02/10/06
12/31/05
Seems kinda random. I've tried tweaking and nothing really affects the results coming out that way.
Any other ideas? Thanks again!
-------------------
abort, retry, fail?
-- modified at 18:25 Monday 23rd January, 2006
|
|
|
|
|
jszpila wrote: My results along these lines (I'm doing some formatting in the SQL - I'm doing the formatting independently with an alias so I don't think it would be messing it up):
01/26/06
01/18/06
01/31/06
01/13/06
02/10/06
12/31/05
Assuming you are doing a differential from today 23-Jan-2006
01/26/06 - 3 days from today
01/18/06 - 5 days
01/31/06 - 8 days
01/13/06 - 10 days
02/10/06 - 18 days
12/31/05 - 23 days
Seems reasonable to me. That's why I put the extra columns in the demonstration code, because it does seem a bit random.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Ah, alright, that makes sense now. I didn't pick up on that right away.
Thanks a ton!
-------------------
abort, retry, fail?
|
|
|
|
|
I have a stored procedure that updates data in one table and saves who updated it and the update date in another table. For some reason, the user ID is updating, but the date isn't. I'm using the GetDate() function, so it should work fine, as far as I know. It's like the update statement doesn't even recognize the second column.
Before you ask, I know the SQL is correct. In fact, if I execute the stored procedure from QA, everything works fine. Are there any issues with using the GetDate() function in a stored procedure? I wouldn't think there are.
Here's my SQL:
UPDATE UserDefinedRows
SET UpdatedByUserId = @UserID,
UpdateDate = GETDATE()
WHERE UserDefinedRowID = @UserDefinedRowID
Michael Flanakin
Web Log
|
|
|
|
|
Oh, and when the SP gets run from the application, it gets run by a DBO user.
Michael Flanakin
Web Log
|
|
|
|
|
I just logged into QA as the user the application is running as and the SP executed fine. I'm still having problems when executing it from the app, tho. This is pretty ridiculous.
Michael Flanakin
Web Log
|
|
|
|
|
UpdateDate = GETDATE()
please past the error message
hint,
if UpdateDate is datatime then it will work properly.
Qaisar Mehmood Mughal
...............................................................................
May Allah gave u success in all fields of life. (Aameen)
...............................................................................
Software Engineer
ISF - Islamabad Software Factory
3rd Floor, Software Technology Park
Constitution Avenue, Islamabad 44000, Pakistan
www.isf.com.pk
qaisar@isf.com.pk , qmmughal@gmail.com
Phone: +92 (51) 2825387 : 0321-5226623
|
|
|
|
|
how to delete a record from the databaseb using ado
yamuna
|
|
|
|
|
yamunasenthilvel wrote: how to delete a record from the databaseb using ado
The simplest way to delete values from a database is.
CString sql = "DELETE * FROM tbl_Name WHERE col =’value’"
pConnection.Execute(sql.AllocSysString(), NULL, adExecuteNoRecords);
|
|
|
|
|
hi..
i have written code for inserting the records into the table but with it itself i need to do deleting and update of records.. how to include those things with in same code.. please help me..
code is
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include "impfile.h"
int main(int argc, char* argv[])
{
HRESULT hr = S_OK;
try
{
CoInitialize(NULL);
// Define string variables.
_bstr_t strCnn("Provider=sqloledb;Data Source=(local);Initial Catalog=pubs;User ID=test;Password=test;");
//_bstr_t strCnn("Server=(local);Database=pubs;Trusted_Connection=Yes");
_RecordsetPtr pRstAuthors = NULL;
// Call Create instance to instantiate the Record set
hr = pRstAuthors.CreateInstance(__uuidof (Recordset));
if(FAILED(hr))
{
printf("Failed creating record set instance\n");
return 0;
}
printf("Created RecordSEt");
//Open the Record set for getting records from Author table
pRstAuthors->Open("SELECT au_lname,au_fname,city FROM Authors",strCnn, adOpenStatic,adLockReadOnly,adCmdText);
printf("Recordset Opened");
//Declare a variable of type _bstr_t
_bstr_t valField1;
_bstr_t valField2;
_bstr_t valField3;
pRstAuthors->MoveFirst();
//Loop through the Record set
if (!pRstAuthors->EndOfFile)
{
while(!pRstAuthors->EndOfFile)
{
valField1 = pRstAuthors->Fields->GetItem("au_lname")->Value;
valField2 = pRstAuthors->Fields->GetItem("au_fname")->Value;
valField3 = pRstAuthors->Fields->GetItem("city")->Value;
printf("%s \t - %s \t - %s \t\n",(LPCSTR) valField2, (LPCSTR) valField1,(LPCSTR)valField3 );
pRstAuthors->MoveNext();
}
}
pRstAuthors->Close();
getch();
}
catch(_com_error & ce)
{
printf("Error:%s\n",ce.Description);
}
CoUninitialize();
return 0;
}
yamuna
|
|
|
|
|
hi...
how to pass muliple option from a drop down to the stored procedure as string and then pass the values to the conditional clause of the procedure.
sathy
|
|
|
|
|
imsathy wrote: muliple option from a drop down
A drop down only permits one option to be selected at a time.
imsathy wrote: to the stored procedure as string
string value = MyDropDownList.SelectedValue;
SqlCommand cmd = new SqlCommand(myConnection, "StoredProc");
cmd.CommandType = CommandType.StoredProcdure;
cmd.Parameters.Add("@paramName", value);
SqlDataReader reader = cmd.ExecuteReader();
imsathy wrote: then pass the values to the conditional clause of the procedure
For example:
CREATE PROCEDURE dbo.StoredProc
@paramName varchar(100)
AS
SELECT * FROM SomeTable
WHERE someColumn = @paramName
GO
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Select Products
im filling this dropdown dynamically thro xml and js
i want the multiple selected values from thus drop to be a comma separated string and pass it as a parameter to a stored procedure..
and is there a way to pass these multiple values to the where clause of the sp
here how to give the multiple values of the serial nos from the string of the sp to this query
SELECT
...
...
...
WHERE serial_number =@serialNo
sathy
|
|
|
|
|
Are you required to use a combobox dropdown? Why I ask is because listboxes can do multiple selections.
PJC
|
|
|
|
|
thanks guru but my requirement is for tht only ....
i have sorted tht out ..
sathy
|
|
|
|
|
Glad you sorted that out.
Have a good day,
Paul
|
|
|
|
|
Hi guys
I have a problem:
I need to execute a command text in a stored procedure
begin
.
.
.
declare @sql nvarchar(1000)
set @sql = '
decalre @v1 int
declare @v2 int
...
'
exec(@sql)
end
i need to get value of @v1 and @v2 after exec(@sql)
without using temporary table.
|
|
|
|
|
WDI wrote: without using temporary table.
@v1 and @v2 exist only within the scope of the EXEC statement, in order to get them out you need to SELECT them and have the EXEC be the source of data for an INSERT statement (normally into a temporary table - although it could be a permanent table).
Why are you not wanting to use a temp table?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
cos I need to execute stored procedure more than 1000 time and i am worry about cpu and memory usage!
|
|
|
|