.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Database record controle

Posted By:      Posted Date: October 24, 2010    Points: 0   Category :ASP.Net

I made a profile page for every user that is logged in. Now when he comes for the first time on that page they have to fill 

in some information.

Iff they visit there profile page for the first time i have to use : SELECT a,b,c FROM d;

When they already filled in the information it must be loaded in textboxes(this already works).

But in that case i have to use UPDATE ...

How can i see when i have to use the UPDATE and SELECT? I have to see if the user already made his profile page...

View Complete Post

More Related Resource Links

Does this look correct for saving a file/ new record to a database


So thank you for all your help so far, So I think i got this right,
but would like for you all to look it over to see if there is any
areas I might run into trouble with:

//using asp.net mvc 2
the table (sql server 2005, using entities framework)
table fields
"Pattern_Media_GUID  uniqueid 
"Pattern_GUID  uniqueid
"Media varbinary(max)  
"height int
"Width int
"Media_Type String (50)

the form:
<h2> Add Media to this pattern</h2>
<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
    <%: Html.Label("height") %>
    <%: Html.TextBox("height") %>

    <%: Html.Label("width") %>
    <%: Html.TextBox("width") %>

    <%: Html.Label("Media") %>
    <input type="file" id="Media" name="Media" />
    <input type="submit" name=

Can this code be setup to run against the whole database instead of just 1 record at a time?


We have made some changes to this code to start capturing 1 new field of data and updating it as new records are added. But there is currently about 120,000 records more or less.. those records of course dont have the new field populated with anything..

We would like to run this logic that already in place and run it against the tables to update the fields 1 time. I think to make it easier, if it can be setup to expect the "valueTwo" variable, so that we can run it againt the individual codes instead of doing all the records at one time.. there are codes that only have a few records, so it would be best to test initially against the small code group.


            strSqual = "insert into trans (trans_type_name, trans_date,sys_id,mod_user_id,show_ind, remoteCode, techName) values('" & valueTwo & "','" & TransDate & "',"&strSystemID&", 1,'T', '" & dbQuote(strUser) & "', '" & strTechName & "')"        
            'get the new transaction_id out for just inserted alarm   
            strSqual = "select max(transaction_id) as transaction_id from trans"  
            set rst = getStaticRecordSet(strSqual)

How to check if record is added in access database



I'm trying to put a registration page together in Visual Web Designer.

I would like to send a confirmation Email after someone is leaving his registration data and pressing the INSERT button.

The key fields in my database are: Email, Name, Surname, Address

Before I send the confirmation Email I would like to check if the email value entered in the form is realy added to the database.

Please for help in this matter. I was copy past already some C code in my page, therefore it will be fine if the code can be in C.

Again, I need help to:

- checking if record is realy added to database after pressing INSERT button

- setup the confirmation Email

Thank you in advance.


How can i check if record already exist in sql-server database ...

How can i check if record already exist in sql-server database ...

Get last record in a SQL database

Don't know if this is the right SQL section, but... using VBE, how do you SQL for the last record in the database?Thanks.

Update Database Record using GridView and Stored Procedure

Hi, I am trying to update record via stored procedure, but i got error at very start point. Problem is when i click on Edit link button within the Gridview it produce error. I can populate values from database fine but its produce error when i click on edit link button. Please see the code below. *********** ASP.net GridView Code I am using *****************<asp:GridView ID="GridView1" runat="server" DataKeyNames="RollID, EmpID" AutoGenerateColumns="False" Width="700px"> <Columns> <asp:TemplateField HeaderText="ApplicationID" Visible="false"> <ItemTemplate> <asp:Label ID="AppsID" runat="server" Visible="false"><%# Eval("RollID") %>'</asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ReleaseID" Visible="false"> <ItemTemplate> <asp:Label ID="rlsID" runat="server" Visible="false"><%# Eval("EmpID") %></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Roll Name"> <ItemTemplate> <asp:Label ID="rlsVersion" runat="server"><%# Eval("Roll_Name")%></asp:Label> </ItemTemplate> <EditI

How to search record from database in windows apllication

I hav to search records from database.Means if i entered B.E. in qualification column then it gives me all the records having qualification as B.E...my db is in sql plz rply me asap.

Database Record to Variable

One way or another I need to loop through a recordset and check to see if the files in the database actually exist on the server. So basically I need to convert the database record into a variable so I can use file.exists How do I do that? Thank you so much for all your help!! 

how do I search record from database and display that in Datagridview.

hi,I am working in windows application.I wanted to search record while entering into textbox and respective data should be displayed in datagridview..

Checking existence of a record in sql database using IF EXIST and reporting outcome on asp page



I have a page that inserts a record to an sql database and I would like to do the following:

(i) Check if a record already exist before trying do an insert

(ii) If a record exist, the page should be able to inform/display a message in a textbox informing the user that the record already exist.


I have seen a number of post on the internet that suggest that one possible solution is to write a sproc and use the T-sql IF EXIST function. However, I have NOT seen a complete code showing (a) how this can be done (b) how to call the sproc from an asp page (c) and MORE IMPORTANTLY how to display a message informing a user that a record already exist i.e. when the record already exist in the database.


Please have anyone got a complete working code that can achieve this preferably in c#?




DataBase maximum table record count


Hello Friends,

My requirement is, we have more than 5 database servers, each server lot of databases, each database lot of tables.

 I want show the details


ServerName: abcServer

DatabaseName: xyzDatabase

MaximumRecordsTableName: empTable


In asp or Classic asp.

please anybody help for code and query.


how to split the connection string in asp ?

reading last 10 record form database


hello sorry for my english

how to read last 10 record from a table for example (tb1) that consist of 3 column

trying to insert a record into database


 I put in break points, the problem starts when I get to this part:

public void InsertClients(string client_name, string client_lastname, int client_age)
            cmd = new SqlCommand();
            cmd.CommandText = "[dbo].[prcinsert_client]";
            cmd.CommandTimeout = 0;
            cmd.CommandType = CommandType.StoredProcedure;

            cn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnectionString"].ToString());
            cmd.Connection = cn;
            cmd.Parameters.Add("@client_name", SqlDbType.VarChar, 12).Value = client_name;
            cmd.Parameters.Add("@client_lastname", SqlDbType.VarChar, 15).Value = client_lastname;
            cmd.Parameters.Add("@client_age", SqlDbType.Int, 4).Value = client_age;

                cmd.ExecuteNonQuery();  // problem is here will not execute the query.
            catch (SqlException)
                throw; // throw it back to the calling method.


I checked I can get all of my values. Here how I save my value in the bll:

public int Save_Client(string clientname, string clie

Problem inserting a record into database

I created a table with a foreign key:
Create table Products
    Pro_ID int Primary key not null, 
    Client_ID int Foreign key (Client_ID) references Client_Details not null,
    [Prod_Name] [varchar](50) NULL,
    Prod_Description varchar(50) null,
    Purchase_Date DateTime Not null,
    Price Money null,
    Delivered int null
I need to populate that table with some data:
insert into Products (Pro_ID,Client_ID,Prod_Name,Prod_Description,Purchase_Date,Price)
values(2024,102,'Valuation Roll 2001','Property Values for 2001',Getdate(),15000)
When I run the query I get an error:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Products__Client__03317E3D". 
The conflict occurred in database "valrollclients", table "dbo.client_details", column 'client_id'.
The st

Cannot update record to database



I encounter some problems on updating the database record and want to find some help. I use the following coding to show a form for receiving the original record and it works:

    <% using (Html.BeginForm()) {%>
        <%= Html.ValidationSummary(true) %>
            <div class="editor-label">
                <%= Html.LabelFor(model => model.userID) %>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.userID) %>
                <%= Html.ValidationMessageFor(model => model.userID) %>
            <div class="editor-label">
                <%= Html.LabelFor(model => model.username) %>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.username) %>
                <%= Html.ValidationMessageFor(model => model.username) %>
            <div class="editor-label">
                <%= Html.LabelFor(model => model.password) %>
            <div class="editor-field">

display a record count from sql database connection


sometimes learning asp.net feels so heavy handed compared to some of the general purpose scripting languages like php.  for examples, all i want to do is create a sql connection that pulls a row count and displays that number.  I don't need a grid, list, detail page, etc., nothing this heavy... a simply query that will display a simple bit of text.  for the life of me I can't figure out how to do it.  Using these controls, I'm not in the code behind with the query, so I wouldn't attach this to a label (or would i), and there's nothing i see in the toolbox that does what i want.  Perhaps i'm too accustomed to php but it feels like with asp.net, major things are simple, and simple things are hard.  any help would be appreciated.  i'm trying to convert my career to c#.net

Need Query to find out the latest record insert in database


Here is my table contain the following fields

   ID    UID    OID   Date  

   1      20       1    2010-11-03 12:22:44.217

   2      30       1     2010-11-03 12:01:09.090  

   3      20      2     2010-11-03 12:22:44.217

   4      40      2   2010-11-03 12:01:09.090

i need the result like

UID   OID    Date

 30     1        2010-11-03 12:01:09.090  

 40     2         2010-11-03 12:01:09.090  

Please help me

20 2 2010-11-03 12:22:44.217
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend