Web Forms :: How To Begin And End Sql Transaction In Code
Feb 5, 2012I have not used sql transactions in my code in asp.net. How to begin and end it.. ?
View 1 RepliesI have not used sql transactions in my code in asp.net. How to begin and end it.. ?
View 1 RepliesI have a stored procedure which is part of the aspnetdb but i am using my own database and therefore these stored procedures are added on my sql server locally.So i uploaded the databases to my hosting company 1and1 and created the stored procedures and tables as those in aspnetdb but i get the error as in the title. this is a standard stored procedure which lives in the aspnetdb database but not sure why this is happeningthe code is below which is for aspnet membership createuser a standard stored procedure
[Code]....
i am trying to send a email with the info supplied from my form. i have got the code from a book im going through ( asp.net 3.5 in c# and vb ). First here is the code behind from the submit button:
Protected Sub btn_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
Dim mailBody As String = System.IO.File.ReadAllText(fileName)
mailBody = mailBody.Replace("##Name##", tb_firstName.Text)
mailBody = mailBody.Replace("##Surname##", tb_surname.Text)
mailBody = mailBody.Replace("##eMail##", tb_eMail.Text)
mailBody = mailBody.Replace("##Subject##", tb_subject.Text)
mailBody = mailBody.Replace("##Description##", tb_description.Text)
Dim myMessage As MailMessage = New MailMessage()
myMessage.Subject = "##Subject##"
myMessage.Body = mailBody
myMessage.From = New MailAddress("jay@jwwebdesign.net", "##Name##")
myMessage.To.Add(New MailAddress("jay@jwwebdesign.net", "Me"))
Dim mySmtpClient As SmtpClient = New SmtpClient()
mySmtpClient.Send(myMessage)
End Sub
and here is the code from the web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod ="Network" from ="Jay <[URL]>">
<network host ="smtp.jwwebdesign.net" />
</smtp>
</mailSettings>
</system.net>
when in debug mode it points the error to being:
smtp exeption was unhandled by user code Transaction failed. The server response was: m1pismtp01-001.prod.mesa1.secureserver.net and it highlights this code:.........
I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and move on. The reason is that the request in question hits an API that then chain hits another one of my pages (near-synchronously) to let me know that it processed, and thus double submits a transaction record, because the original request had not yet finished, and thus not committed the transaction record.
So I've tried wrapping the insertion code with a new SessionScope, TransactionScope(TransactionMode.New), combination of both, flushing everything manually, etc. However, when I call Refresh on the object I'm still getting the old object state. Here's some code sample for what I'm seeing:
Post outsidePost = Post.Find(id); // status of this post is Status.Old
using (TransactionScope transaction = new TransactionScope(TransactionMode.New))
{
Post p = Post.Find(id);
p.Status = Status.New; // new status set here
p.Update();
SessionScope.Current.Flush();
transaction.Flush();
transaction.VoteCommit();
}
outsidePost.Refresh();
// refresh doesn't get the new status, status is still Status.Old
I have a placeholder (in tr tags) which I fill with dynamic images. Is it possible to automaticaly begin a new row (tr) after 5 columns (td)?
[Code]....
I cant even seem to start. i drag the chart icon into the ground and then the sqldatasource. tie them too together. and then im completely lost. i tried tieing x&y values with sum,customer name but they just arent working correctly
View 1 RepliesI have an HTML text that I get from
WebResponse webResponse = Req.GetResponse();
now all i need it text between "<ol>" and "</ol>" tags.
how would i get this using regular expressions?
Without using a third-party control, is it possible to automatically begin uploading a file as soon as the user selects a file and the file browser window closes? I have the data struture in place as well as all the information needed to capture the data, but I need a way of knowing if the file upload has changed? Is there an event that fires, or something I can capture to achieve this?
View 1 RepliesA bit of background: I am familiar with PHP and Java, did some C, C++ and Lisp (gasp!) back in programming classes but never used them too much. So, I've been wanting to step out of PHP a bit for web development. I have a few reasons for this (in no particular order): there's a lot of amateurish code(rs) in PHP, which somehow makes me look bad; I am unhappy with a few quirks in the language; and I really want to try something new. Here are the options I've been looking at:
Python and Ruby (on Rails): They both seem nice, but it looks like I'll have some difficulty finding webhosts that run these. And it appears that Python scripts aren't as portable as PHP (correct me if I am wrong).SP.NET: I have an issue with Microsoft software kind of existing in their own realm. I mean, MS has some really good tools for developers and if you stay within those tools your life is easy. But if you deviate just a bit out of it, you are on your own. And oh, it's not opensource.
So what do you recommend? And if I go with Python (it's tempting), should I use a framework like Django or web2py or should I go down and dirty with the basics (same thing with ASP.NET and MVC)?
EDIT: What I don't like about PHP:
No namespaces
Implicit type conversions can cause problems
Many silent errors
No unicode support
Slow
....
I'm trying to set the datatype of my DataColumn like this:
[Code]....
But I get an error that says Name cannot begin with '>' character.
how get Method Begin Request&EndRequest In UpdatePanel?(in jquery)
function onBeginRequest()
{
//$.blockui;
}
function onEndRequest()
{
//$.unblockui;
}
its simple question: if my edit cursor in at line 1 I wantto Quick jump to 5 and backforth again (to line 1)
is there a Jump Shortcut between Corresponing End/Begin tags ?
1. <blah>
2. ...
3. ...
4. ...
5. </blah>
I am seeing things that lead me to believe that using data aware controls is almost the opposite of what VC tries to do? But how can I recoupe the advantages of a data aware control and cooperate with the MVC Model?
View 2 Repliesi was wondering if i could capture transaction time automatically. e.g. if form has a grid submit button and user clicks submit button to submit changes on a grid to database, is there a way to capture start time when user clicked the button and reply user got back from page?
View 3 RepliesWhat control do you use for detail data transaction ?
i am thinking of GridView, however, it lacks of add new row function and lack of bulkediting.
then i found RealWorld BulkEditGridView, it's a good in handling bulkedit, and has new row function, however, it can function well only on load. the problem will appear if i add up a new button, which function to add up InsertRowCount property, a row is created as expected, however, all my previous entry in "new row" are gone.
I have a dataset which includes some Queries. Now I want to use my queries which I created with the dataset through sql transaction. I have two queries that must execute at the same time and if anything goes wrong it should roll back. Is it possible to use Sql Transaction with Dataset queries?
View 3 RepliesI want to delete file available on server and same time I want to update the filename column in my database.If I delete file first and then update database and an error come in updating database my file is already gone.If I update database first and then delete file from from disk and an error occur my file information in database is already gone Can any one tell me how I can do it both successfully. I means either both operations should succeed or I should not lose my physical file or its information in database.
View 3 RepliesHow to create a master form , transaction page .....
View 1 Repliesi redirect a page from http to https using http module begin request handler .i am calling webservice using ajax but it is saying webserice not defined .which otherwise works fineits work fine when rediect page in page_load instead .but i need to add function for https to http in every page. i still not know why ajax is not working when i use http module for redirect
View 3 RepliesHere is my connection string...?? I cannot for the life of me find out where I'm missing a >, or where there is an invalid < .. the debugger directs me here....
<connectionStrings>
<add name="dbnameremoved" providerName="System.Data.Sql.Client" connectionString="server=dbserverremoved;database=dbremoved;uid=username;pwd=password" />
</connectionStrings>
We can catch the error log information by use EXEC xp_readerrorlog. I am just wondering is SQL have other types of log for us to reference information
I didn't wrote trigger for my tables... one table was missing, would it possible to know when the table was be deleted by some kind of transaction log?
What is the best way to format a transaction id?Conditions Max 15 characters: XXXXXXXXXXXXXXX -All transaction must be unique -Can contain both numerical and alphabetical characters -May contain Year, month, day
View 1 Replies disconnected mode and transaction.it's give to me ERROR message
Quote.ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized
PHP Code:
da.InsertCommand = cb.GetInsertCommand
my code is:
PHP Code:
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DBCon").ConnectionString)
Dim cmd As New SqlCommand("insert into Customer (customer_id, customer_name, note) values (@cid, @cname, @note)", con)
Dim da As New SqlDataAdapter("select * from CustomerPhone", con)
| [code]....
table 1
[Code]....
Table 2
[Code]....
my stored procedure
[Code]....
when ever i m passing the wrong the value in second table while updating its not updating the table but the problem it is inserting the value in first table i want the whole trans should proceed if success if not rollback
I know these 2 commands
sp_who and sp_who2 → knowing who are updateing
DBCC log (DB_NAME,4) → I can't really understand these information..
just wondering does there exists a log file, so we can check who have updated database from it?