Click here to Skip to main content
15,896,207 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to show bargraph in asp.net webpages Pin
mr_muskurahat27-Oct-08 21:04
mr_muskurahat27-Oct-08 21:04 
GeneralRe: How to show bargraph in asp.net webpages Pin
LloydA11129-Oct-08 6:49
LloydA11129-Oct-08 6:49 
QuestionOnline shopping using MIGS Pin
Blumen27-Oct-08 19:45
Blumen27-Oct-08 19:45 
QuestionAsp.net 2.0 with MYSQL Database server help is needed Pin
Rameez Raja27-Oct-08 18:46
Rameez Raja27-Oct-08 18:46 
AnswerRe: Asp.net 2.0 with MYSQL Database server help is needed Pin
AhsanS27-Oct-08 20:47
AhsanS27-Oct-08 20:47 
AnswerRe: Asp.net 2.0 with MYSQL Database server help is needed Pin
N a v a n e e t h27-Oct-08 21:59
N a v a n e e t h27-Oct-08 21:59 
QuestionASP Menu Controls and Query Strings Pin
RB@Emphasys27-Oct-08 18:28
RB@Emphasys27-Oct-08 18:28 
QuestionHow prevent duplicate record run update statement else Insert Statement Pin
zjaffary27-Oct-08 16:58
zjaffary27-Oct-08 16:58 
I have a Table.It is containing 4 column RegionID, MapFillColor, MapLineColor, MapCoordinates.

I want to run insert statement if the record is new when button press. But if the record already exist it should update the record REGIONID is primary Key in my Table. I donot know where i should put my function which check first the record exist if so then run update else insert statement.

Here is my Code

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page

{

SqlConnection con = new SqlConnection("Data Source=ZAFAR-PC\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

SqlCommand cmd = new SqlCommand("Insert into Region(RegionID,MapFillColor, MapLineColor, MapCoordinates) values( '" + RegionID_txt + "','" + MapFillColor_txt + "','" + MapLineColor_txt + "','" + MapCoordinates_txt + "')", con);

con.Open();

cmd.ExecuteNonQuery();

con.Close();

}

}
AnswerRe: How prevent duplicate record run update statement else Insert Statement Pin
Kannan Ar27-Oct-08 18:56
professionalKannan Ar27-Oct-08 18:56 
AnswerRe: How prevent duplicate record run update statement else Insert Statement Pin
meeram39527-Oct-08 21:04
meeram39527-Oct-08 21:04 
AnswerRe: How prevent duplicate record run update statement else Insert Statement Pin
Michael Bookatz28-Oct-08 2:17
Michael Bookatz28-Oct-08 2:17 
QuestionJavascript Issue -Not working in Firefox Pin
Ridge Howison27-Oct-08 11:21
Ridge Howison27-Oct-08 11:21 
AnswerRe: Javascript Issue -Not working in Firefox Pin
Guffa27-Oct-08 16:12
Guffa27-Oct-08 16:12 
QuestionFormat the XML file With Asp.net Csharp Pin
zjaffary27-Oct-08 10:36
zjaffary27-Oct-08 10:36 
AnswerCross post and Repost Pin
led mike27-Oct-08 11:02
led mike27-Oct-08 11:02 
QuestionEdit mode in GridView changes column width Pin
Pravinc198427-Oct-08 8:52
Pravinc198427-Oct-08 8:52 
AnswerRe: Edit mode in GridView changes column width Pin
meeram39527-Oct-08 21:17
meeram39527-Oct-08 21:17 
QuestionTimeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
AndersgRex27-Oct-08 6:40
AndersgRex27-Oct-08 6:40 
AnswerRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Rutvik Dave27-Oct-08 6:53
professionalRutvik Dave27-Oct-08 6:53 
AnswerRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
AndersgRex27-Oct-08 8:31
AndersgRex27-Oct-08 8:31 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Ashfield27-Oct-08 9:48
Ashfield27-Oct-08 9:48 
QuestionGridView, DetailView and Creating a New Row Pin
Pravinc198427-Oct-08 6:31
Pravinc198427-Oct-08 6:31 
QuestionAJAX update panel Pin
geletaabate27-Oct-08 6:27
geletaabate27-Oct-08 6:27 
Questionvb.net and parsing xml string Pin
KingAndyb27-Oct-08 3:57
KingAndyb27-Oct-08 3:57 
QuestionNEED HELP: Runing proces using the process.start() Pin
sSupergirl27-Oct-08 2:04
sSupergirl27-Oct-08 2:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.