|
mark merrens wrote:
Is ... this a quiz?
Does it look like that? Perhaps it is. But you did not win the prize of my 5.
|
|
|
|
|
Bernhard Hiller wrote: Can you guess what went wrong here?
Old statistics?
|
|
|
|
|
Thanks for this idea. The statistics did not bring improvement. Eventually an index on column Table1ID of Table2 brought the solution.
|
|
|
|
|
I have configured SQL Server 2008 Enterprise --Database Mail with the SQL below. But when I try to send mails with my hotmail e-mail account, I just get the error message(
select * from msdb.dbo.sysmail_event_log; ):Quote: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 24 (2011-11-17T17:20:53). Exception Message: Could not connect to mail server. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.53.109:25)
I have tried several email account, like hotmail(smtp.live.com), QQ(smtp.qq.com), gmail(smtp.gmail.com) and 163(smtp.163.com), but what I got was the same message as above.
Any help would be greatly appreciated!
-- ENABLE DATABASE MAIL FEATURE IN SYSTEM CONFIGURATION
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'Database Mail XPs',1
go
reconfigure
go
-- DECLARE DATABASE MAIL ACCOUNT PARAMETERS
Declare @qmail_account_name as varchar(64);
Declare @qmail_account_description as varchar(64);
Declare @qmail_account_email_address as varchar(64);
Declare @qmail_account_display_name as varchar(64);
Declare @qmail_account_username as varchar(64);
Declare @qmail_account_password as varchar(64);
Declare @qmail_account_mailserver_name as varchar(64);
-- DECLARE PROFILE PARAMETERS
declare @qmail_profile_profile_name as varchar(64);
declare @qmail_profile_description as varchar(64);
-- DECLARE PRINCIPLES
declare @qprincipal_name as varchar(16);
-- SET SMTP ACCOUNT DETAILS, USERNAME AND PASSWORD HERE
set @qmail_account_mailserver_name = 'smtp.live.com'-- SMTP Server Name
set @qmail_account_username='hellomoney' -- SMTP User Name
set @qmail_account_email_address = 'hellomoney@hotmail.com' -- Email Address
set @qmail_account_password='123' -- PASSWORD FOR SMTP User
set @qmail_account_name = 'TestAdministrator'
set @qmail_account_description = 'Mail account for administrative e-mail.'
set @qmail_account_display_name = 'Test Automated Mailer'
-- PROFILE PARAMETERS ASSIGNMENT
set @qmail_profile_profile_name = 'MyEmailServiceProfile'
set @qmail_profile_description = 'Profile used for database mail jobs'
--PROFILE TYPE
set @qprincipal_name= 'public'
if ( @qmail_account_mailserver_name = '' or @qmail_account_username='' or @qmail_account_email_address = '' or @qmail_account_password='' )
begin
Select 'Please enter SMTP details' as [Comments]
end
else
Begin
if exists(select * from msdb.dbo.sysmail_account where [name]=@qmail_account_name)
begin
exec msdb.dbo.sysmail_delete_account_sp @account_name = @qmail_account_name
end
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = @qmail_account_name,
@description = @qmail_account_description,
@email_address = @qmail_account_email_address,
@display_name = @qmail_account_display_name,
@username=@qmail_account_username,
@password=@qmail_account_password,
@mailserver_name = @qmail_account_mailserver_name
if exists(select * from msdb.dbo.sysmail_profile where [name]=@qmail_profile_profile_name)
begin
exec msdb.dbo.sysmail_delete_profile_sp @profile_name = @qmail_profile_profile_name
end
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = @qmail_profile_profile_name,
@description = @qmail_profile_description
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = @qmail_profile_profile_name,
@account_name = @qmail_account_name,
@sequence_number = 1
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = @qmail_profile_profile_name,
@principal_name = @qprincipal_name,
@is_default = 1 ;
end
|
|
|
|
|
Caveat I almost never use sql mail.
Are you sure that you can use a public SMTP server from sql mail. It would never occur to me to try, we always use an internal server.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
im very new to asp.net.
i develop a website for e-commerce..now i developing a page to display the statistic of the product that bought by costumer..
here is my database structure..
Table Product-ProductID,ProductName,Description
Table Transaction-TransactionID,User,ProductID,Quantity
-in table Transaction, i store the product that bought by user with user name and quantity.
-table product, store the information about product
-this is my data, assume Bag ProductID=1 and Pencil ProductID=1 in table transaction..
-for table transaction:
TransactionID | User | ProductID | Quantity
1 | ali | 1 | 2
1 | abu | 2 | 3
1 | qwe | 1 | 5
i want make a statistic about the product that bought by users..
im using this Select query= "SELECT Product.ProductName, COUNT(Transaction.ProductID) AS ProductCount FROM Product INNER JOIN Transaction ON Product.ProductID = Transaction.ProductID GROUP BY Product.ProductName"
when using this query the result is,
ProductName | ProductCount
Bag | 2
Pencil | 1
i just want my result shown like i stated below..but i dont know how to do it..
ProductName | ProductCount
Bag | 7
Pencil | 3
please help me....
|
|
|
|
|
Instead of COUNT() try using SUM(Quantity)
BTW don't put ALL your question in code brackets, just the actual code snippets
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i will try..im very new to this site.so i dont know how to use forum yet.
|
|
|
|
|
You're doing fine, sensible question and layout is not critical, glad to be of service!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks ..it works ..
|
|
|
|
|
my database on sql server 2005, and i was convert my project VC++ to unicode,
the problem is :
when i try to read a field value string from recordset the data is "??????" the code is:
_variant_t vFieldName (strFieldName);
_variant_t ret = m_rs->GetFields ()->GetItem (vFieldName)->GetValue();
CString str = (wchar_t *)(_bstr_t)vVal;
when the language string is english ok but when it in other language the string is "???????"
mazen keeikati
|
|
|
|
|
my database on sql server 2005, and i was convert my project VC++ to unicode,
the problem is :
when i try to read a field value string from recordset the data is "??????" the code is:
_variant_t vFieldName (strFieldName);
_variant_t ret = m_rs->GetFields ()->GetItem (vFieldName)->GetValue();
CString str = (wchar_t *)(_bstr_t)vVal;
when the language string is english ok but when it in other language the string is "???????"
|
|
|
|
|
This implies that your fields in the database are varchar and not nvarchar.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks
when i convert the field type from varchar to nvarchar the problem fixed.
|
|
|
|
|
Keep in mind that it also doubles the size (in bytes) of the field!
|
|
|
|
|
The stumper of the week for me is determining how to link together the DataGridView, BindingSource, TableAdapter, and DataSet in order to make the data entered by the operator flow into the actual SQL Server database. I've spent a week searching for an example without hitting pay dirt. Can someone point me to a decent tutorial on the subject?
Will Rogers never met me.
|
|
|
|
|
|
Both look like excellent articles - Thanks!
Will Rogers never met me.
|
|
|
|
|
Might I suggest you forego the tutorials on DataSets and Table Adapters and concentrate on learning ADO.Net right from the start. It would serve you much better in the long run, particularly if you want to start implementing n-Tier design and OOP, and maybe go on to WPF. There are lots of good tutorials out there, here are a few:-
Using ADO.NET for beginners[^].
Overview of ADO.Net[^]
The C# Station ADO.NET Tutorial[^].
Anyway that is just my 2 cents.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I've been using ADO.Net, but never tried using a DataGridView, and it seems to be made to utilize the mucky triumvirate of DataSet, TableAdapter, and BindingSource if one can believe the documentation. I just thought it would be nice for once to try what Microsoft intends, rather than going my own way as I usually do.
Will Rogers never met me.
|
|
|
|
|
I have always found it much easier to implement my own methods for populating, paging and editing in the DataGridView using POCO classes filled by using ADO than using DataSets to be honest.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
hi,
i am inserting values in such format:
first add column than insert its value,than add second column but here the ALTER TABLE gives error after INSERT INTO in same table.
please help me how can i do this.
thanks.
|
|
|
|
|
|
CDatabase database;
CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)";
CString sExcelFile =_T("C:\\Users\\Admin\\Desktop\\1.xls");
CString Query_Str="";
TRY
{
Query_Str.Format(_T("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s"),
sDriver, sExcelFile, sExcelFile);
if( database.OpenEx(Query_Str,CDatabase::noOdbcDialog) )
{
Query_Str = "CREATE TABLE demo (Name TEXT)";
database.ExecuteSQL(Query_Str);
Query_Str = "INSERT INTO demo (Name) VALUES ('Albert')";
database.ExecuteSQL(Query_Str);
Query_Str = "ALTER TABLE demo ADD Col2 TEXT";
database.ExecuteSQL(Query_Str);
}
database.Close();
}
CATCH_ALL(e)
{
AfxMessageBox(e->ReportError());
}
END_CATCH_ALL;
can u please help me to ALTER TABLE with DEFAULT
modified 15-Nov-11 2:31am.
|
|
|
|
|
First add all the columns and do the insert when all columns are present, or make sure that the column you're going to add accepts null-values.
Bastard Programmer from Hell
|
|
|
|