Click here to Skip to main content
15,886,919 members
Home / Discussions / Database
   

Database

 
Questionmanaging database queries Pin
DSPCottage28-Oct-08 10:36
DSPCottage28-Oct-08 10:36 
QuestionSaving changes to a database via Windows forms Pin
danielhasdibs28-Oct-08 7:01
danielhasdibs28-Oct-08 7:01 
QuestionProblem with query pulling from AS400 Pin
missyd28-Oct-08 6:52
missyd28-Oct-08 6:52 
Questionexplain entity storingduef Pin
Member 564239427-Oct-08 21:03
Member 564239427-Oct-08 21:03 
QuestionEmbedding Pin
AnieMVC27-Oct-08 18:59
AnieMVC27-Oct-08 18:59 
QuestionMYSQL Help is needed Pin
Rameez Raja27-Oct-08 18:44
Rameez Raja27-Oct-08 18:44 
AnswerRe: MYSQL Help is needed Pin
Blue_Boy28-Oct-08 0:22
Blue_Boy28-Oct-08 0:22 
QuestionHow to Check Existing Record first then Insert otherwise update statement Pin
zjaffary27-Oct-08 16:57
zjaffary27-Oct-08 16:57 
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 to Check Existing Record first then Insert otherwise update statement Pin
Blue_Boy28-Oct-08 0:20
Blue_Boy28-Oct-08 0:20 
AnswerRe: How to Check Existing Record first then Insert otherwise update statement Pin
Tim Carmichael28-Oct-08 2:02
Tim Carmichael28-Oct-08 2:02 
QuestionCopying data in one table to specific fields in another table Pin
Member 365120927-Oct-08 1:22
Member 365120927-Oct-08 1:22 
AnswerRe: Copying data in one table to specific fields in another table Pin
Wendelius27-Oct-08 10:00
mentorWendelius27-Oct-08 10:00 
QuestionError:The cursor does not include the table being modified or the table is not updatable through the cursor Pin
V K 226-Oct-08 19:19
V K 226-Oct-08 19:19 
AnswerCross-post (3/3) Pin
Wendelius27-Oct-08 9:21
mentorWendelius27-Oct-08 9:21 
AnswerCP IGNORE THIS USER Pin
leckey27-Oct-08 10:00
leckey27-Oct-08 10:00 
QuestionProblem : Retrive Data with ref table Pin
Ahmed R El Bohoty26-Oct-08 1:14
Ahmed R El Bohoty26-Oct-08 1:14 
AnswerRe: Problem : Retrive Data with ref table Pin
Wendelius26-Oct-08 1:34
mentorWendelius26-Oct-08 1:34 
QuestionRe: Problem : Retrive Data with ref table Pin
Ahmed R El Bohoty26-Oct-08 1:53
Ahmed R El Bohoty26-Oct-08 1:53 
AnswerRe: Problem : Retrive Data with ref table Pin
Wendelius26-Oct-08 2:06
mentorWendelius26-Oct-08 2:06 
GeneralRe: Problem : Retrive Data with ref table Pin
Ahmed R El Bohoty26-Oct-08 4:21
Ahmed R El Bohoty26-Oct-08 4:21 
GeneralRe: Problem : Retrive Data with ref table Pin
Wendelius26-Oct-08 5:28
mentorWendelius26-Oct-08 5:28 
GeneralRe: Problem : Retrive Data with ref table Pin
Ahmed R El Bohoty26-Oct-08 8:15
Ahmed R El Bohoty26-Oct-08 8:15 
GeneralRe: Problem : Retrive Data with ref table Pin
Wendelius26-Oct-08 8:23
mentorWendelius26-Oct-08 8:23 
GeneralRe: Problem : Retrive Data with ref table Pin
Ahmed R El Bohoty26-Oct-08 8:25
Ahmed R El Bohoty26-Oct-08 8:25 
GeneralRe: Problem : Retrive Data with ref table Pin
Wendelius26-Oct-08 8:33
mentorWendelius26-Oct-08 8:33 

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.