Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Friday, March 23, 2012

Failed to enable constraints

I have to admit I'm pretty new to ASP.net.

I'm trying to insert a row of data into my SQLExpress database table "Prets"

I'm getting the user_ID from the table "Membres"

Here's the code I have:

Imports System.Web.UI.Page
Imports System.Security.Principal
Imports WiseNetTableAdapters

PartialClass membre_sec_Pret_demande_pret
Inherits System.Web.UI.Page

Protected Sub submit_btn_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles submit_btn.Click
Dim UserAs String = My.User.Name
Dim pretAdapterAs New PretsTableAdapter
Dim membreAdapterAs New MembresTableAdapter
pretAdapter.AjouterPret(Convert.ToInt32(membreAdapter.GetUserIDbyName(User)), Convert.ToDecimal(montant_txt.Text), Convert.ToString(raison_txt.Text))
End Sub
End Class

And here's the error I get at runtime:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Source Error:

Line 1610: }Line 1611: WiseNet.MembresDataTable dataTable = new WiseNet.MembresDataTable();Line 1612: this.Adapter.Fill(dataTable);Line 1613: return dataTable;Line 1614: }


Source File:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\wisenetindustries\afc388c7\16067f12\App_Code.tyietv41.0.cs Line:1612

Stack Trace:

[ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.] System.Data.DataTable.EnableConstraints() +1820725 System.Data.DataTable.set_EnforceConstraints(Boolean value) +39 System.Data.DataTable.EndLoadData() +138 System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) +218 System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) +318 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +221 System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +162 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +107 WiseNetTableAdapters.MembresTableAdapter.GetUserIDbyName(String nom) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\wisenetindustries\afc388c7\16067f12\App_Code.tyietv41.0.cs:1612 membre_sec_Pret_demande_pret.submit_btn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WiseNetIndustries\membre_sec\Pret\demande_pret.aspx.vb:12 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Make sure you have not insert duplicate values on the primary key column, you may take a look at this post:

http://forums.asp.net/thread/1213814.aspx

sql

Wednesday, March 21, 2012

failed to connect to SQL server from asp.net

Hello,
I have an asp.net application which connects to SQL server using the
normal ado.net mechanism. One customer cannot get it to connect to the
database. his connection string is
user id=aaaa;password=bbbb;initial catalog=cccc;server=dddd
and he gets the message:
Cannot open database requested in login 'cccc'. Login fails. Login
failed for user 'aaaa'.
The customer insists that he has the values in the connection string
correct; the only unusual thing is that dddd is actually the IP address
rather than the host name of the SQL server box.
I am not in a position to do any direct investigation myself. many
other customers are using the same software without problems. does
anyone have any clues what might cause this error, other than invalid
username/password combination?
TIA
Andyajfish@.blueyonder.co.uk wrote:
> Hello,
> I have an asp.net application which connects to SQL server using the
> normal ado.net mechanism. One customer cannot get it to connect to the
> database. his connection string is
> user id=aaaa;password=bbbb;initial catalog=cccc;server=dddd
> and he gets the message:
> Cannot open database requested in login 'cccc'. Login fails. Login
> failed for user 'aaaa'.
> The customer insists that he has the values in the connection string
> correct; the only unusual thing is that dddd is actually the IP
> address rather than the host name of the SQL server box.
> I am not in a position to do any direct investigation myself. many
> other customers are using the same software without problems. does
> anyone have any clues what might cause this error, other than invalid
> username/password combination?
>
That's the only cause I know of.
if the IP address was the problem, he would be getting a "not found"
message rather than "login failed", which implies a connection to the
database was initiated, but terminated due to improper credentials.
The customer should check the sql error logs as well as the event logs
to see if any other errors or warnings are present.
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||If the Sql Server is not enabled for "Mixed mode" (both SQL and Windows)
authentication, they could possibly get that error.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"ajfish@.blueyonder.co.uk" wrote:

> Hello,
> I have an asp.net application which connects to SQL server using the
> normal ado.net mechanism. One customer cannot get it to connect to the
> database. his connection string is
> user id=aaaa;password=bbbb;initial catalog=cccc;server=dddd
> and he gets the message:
> Cannot open database requested in login 'cccc'. Login fails. Login
> failed for user 'aaaa'.
> The customer insists that he has the values in the connection string
> correct; the only unusual thing is that dddd is actually the IP address
> rather than the host name of the SQL server box.
> I am not in a position to do any direct investigation myself. many
> other customers are using the same software without problems. does
> anyone have any clues what might cause this error, other than invalid
> username/password combination?
> TIA
> Andy
>|||"Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
news:enZRMTliGHA.4776@.TK2MSFTNGP05.phx.gbl...
> ajfish@.blueyonder.co.uk wrote:
> That's the only cause I know of.
when I looked at the error message a little closer and reproduced it, I
realised the problem was actually down to the database name being incorrect,
not the username and password
d'oh !

> if the IP address was the problem, he would be getting a "not found"
> message rather than "login failed", which implies a connection to the
> database was initiated, but terminated due to improper credentials.
> The customer should check the sql error logs as well as the event logs
> to see if any other errors or warnings are present.
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>|||"Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
news:enZRMTliGHA.4776@.TK2MSFTNGP05.phx.gbl...
> ajfish@.blueyonder.co.uk wrote:
> That's the only cause I know of.
when I looked at the error message a little closer and reproduced it, I
realised the problem was actually down to the database name being incorrect,
not the username and password
d'oh !

> if the IP address was the problem, he would be getting a "not found"
> message rather than "login failed", which implies a connection to the
> database was initiated, but terminated due to improper credentials.
> The customer should check the sql error logs as well as the event logs
> to see if any other errors or warnings are present.
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>

Failed to call SSIS package from ASPX C# Web Page

Hi, Everyone:

I am getting the following error message when I try to execute a SSIS package from an asp.net page written in C# 2.0. What I am trying to do is basically just click on a button in the web page and it will execute the package. The code to execute the package is pretty simple. I pass the path of the DTS package stored in the local folder. This works fine in the machine where SQL2005 is installed locally. But it fail when I have a seperate Web Server and SQL Server. Any ideas? Do I have to install SSIS or SQL2005 on a web server as well?

Thanks

static public string Execute_SSIS_DTS(string DTS_Path)

{

Microsoft.SqlServer.Dts.Runtime.Application app;

app = new Microsoft.SqlServer.Dts.Runtime.Application();

Package package = app.LoadPackage(DTS_Path, null);

DTSExecResult result = package.Execute();

return result.ToString();

}

Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.

Line 226: static public string Execute_SSIS_DTS(string DTS_Path)

Line 227: {

Line 228: Application app = new Application();

Line 229: Package package = app.LoadPackage(DTS_Path, null);

Line 230: DTSExecResult result = package.Execute();

[COMException (0x80040154): Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.]
Microsoft.SqlServer.Dts.Runtime.Application..ctor() +43

[DtsPipelineException: Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.]
Microsoft.SqlServer.Dts.Runtime.Application..ctor() +169
Utilities.Execute_SSIS_DTS(String DTS_Path) in c:\Inetpub\wwwroot\MasterTables\App_Code\Utilities.cs:228
MasterTables_Admin_MasterTables_LOINC_External.btn_SyncLISTest_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\MasterTables\MasterTables_Custom\MasterTablesCustom_LOINC_External.aspx.cs:98
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +141
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3215

Yes, to use SSIS object model and to execute package you do need to install SSIS on this machine, of course.

See my blog entry for some more details
http://blogs.msdn.com/michen/archive/2006/08/11/package-exec-location.aspx

Friday, March 9, 2012

Fail to Invoke Job from ASP .NET

Hi,

I have an ASP .NET page which invoke a SQL Agent Job. It works fine in debugging but when I run the web application in deplyment environnment it does not work. The Web Application is configured in Basic Authentication. The error message is not very detailed: "Invoke failed to job XXX".

I tried to add credentials information in my code using:

myServer.ConnectionContext.LoginSecure = false;
myServer.ConnectionContext.Login = "DOMAIN\Login";
myServer.ConnectionContext.Password = "pwd";

or


myServer.ConnectionContext.LoginSecure = false;
myServer.ConnectionContext.ConnectAsUserName = "DOMAIN\Login";
myServer.ConnectionContext.ConnectAsUserPassword = "pwd";

but it does not change anything.

Any help will be appreciated.

When you specify LoginSecure=false you're telling the server to use a SQL login, then you're supplying a domain login. You need to establish a SQL Login with the necessary credentials on the server in this circumstance.|||Hi,

if you want to impersonate the curretn thread with another security token than the actual it is running on (as you told the basic authentication) you will have to create an impersonation context, if you want to use the current security context your can just set the LoginSecure = true.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de