DataSource Controls :: How To Check If Identity_Insert Is On Or Off
Jan 13, 2010How can I check if IDENTITY_INSERT is on or off for a table in my DB?
View 4 RepliesHow can I check if IDENTITY_INSERT is on or off for a table in my DB?
View 4 RepliesThe wierd thing is this was working fine and then it just started throwing this error,
"Cannot insert explicit value for identity column in table 'Reports' when IDENTITY_INSERT is set to OFF."
Here is the code:
[Code]....
I've got 2 tables where each has a primary key which is also the identifier (Both fields called "id" in each table) In the "picture" table as one of the fields I've got the photoalbumid (The id of the "photoalbum" table). This field is just an int field. I'm getting the following error: "Cannot insert explicit value for identity column in table 'Picture' when IDENTITY_INSERT is set to OFF" Can anyone give me some advise? It's such a basic thing I would hope that there's just something small in the creation of the database that I've missed out. Let me know if you need more info.
View 9 Repliesim using sql server 2008
as per microsoft, [URL]
when i execute the following
set identity_insert on
//insert statements here
set identity_insert off
the identity of the column is set to the maximum value. can i aviod this.
consider the following scenario,
my table has 2 rows as follows
id, name comm
1, John, 232.43
2, Alex, 353.52
now using the above code, when i insert
10, Smith, 334.23
as per the above link, sql server automatically sets the identity to 10. so for newly inserted records(without using identity_insert on), id automatically starts with 11.
i want the identity value to be 3, after using identity_insert on/off
I have the following SQL update statement.
[Code]....
What I am looking to do is when I run the srcipt, I want to check to see if this has been run or not. If it hasn't been run then I would like it to update the record, if it has been run then I don't want it to update.
Just have a problem, I want people to join a mailing list, I just have a textbox and button. When a user enter's their email address, the address and time are inserted into a database. However, if the same email is added again I would like for a message to appear saying the record already exists.
Can someone show me how to do this, here is my current code:
[Code]....
Here I have specified a query which gives an idea about how to drop a constraint and recrate it..
[Code]....
Parent_TableName: is the name of the table where we actually reffer.
I have a situation where a query returns ~20 columns, but at any given execution only 5 of the 20 will have non-NULL values. The remaining 15 will contain null for every row in those columns.
I need to figure out which of the 5 columns have values. I am using a SqlCommand. How would I best approach figuring out these 5 columns?
i have a job application process where users apply for a job, in the admin section administrators want to be able to see which applications have not been viewed. Now i have one page which lists all the job vacancies and then users can click into that specific vacancy to see which people have submitted an application. This all works fine.
However on the page i display the job vacancies i need to make it so that if there are any applications within a vacancy that need viewing it appears in RED.
The two tables i am using are below:
tbl_vacancies
job_id
job_name
location
voucher
details
availability
region
date_added
tbl_applications
application_id
job_id
fname
sname
other_info
.
.
.
.
date_addedd
viewed
Now the viewed column is in tbl_applications table, the applications relate to a specific vacancy via the job_id.
So what i need to check is IF there are ANY applications where the viewed = 0, if so that means that there are applications that need to be seen, and i want this to appear in RED.
Now i tried this several ways i.e an INNER JOIN etc.. but the full list of vacancies won't appearing.
So i tried this:
[Code]....
[Code]....
This doesnt work at all. I have a datareader which runs through the returns, i don't get any errors, and the applications display correctly but when i use the IF to check it doesnt work..
I am having a problem. I need to check to see if a row has been displayed once, and if so don't display it again. I have the following code:
[Code]....
This all works perfectly, but displays the body row repeatedly. So i need to add a counter or something to check this and make sure it is only displayed once..
I tried with DISTINCT in the sql but that didn't work, so i think it may be better doing it through iteration? Can this be done?
I have webform which has insert button to insert/Add new record into my database table. It works fine but the problem is that I have a unique field name of the field is txtQuotes ,The user should not be able to insert a record that contains the same value for that field.How can I check for duplicate?
View 5 RepliesHow do I check if my value is empty AND Isnull? I need to check for both, using ISNULL is not enough because the data can change just so that it is empty.
how I can change my query to accommodate this?
[Code]....
I want to check if an sqlparameter exists before adding a new one so I don't get the error - @param was supplied multiple times. IS this possible?
View 7 Replieshow to check if the particular values in a table exists?
if it is not existing i need to insert that values in the table?
[Code]....
but if table is empty i.e. there is no record for Store_no=storeno then it bill_id = (Convert.ToInt32(reader[0]) + 1); give a Null exception.
I want to set bill_id=1 if there is no previous record in table of that particular store number. then How to do this.
i.e. How to check that reader[0] is null
cmd1 = new SqlCommand(" Select Max(Bill_No) From Bill_Record Where Store_no='" + storeno + "'", hookUp);
how to wrote stored procedure for check two queries result this result is same return true value its not same return false value
View 2 Replieshow check connection with data base? Now I all query put in try and catch. But I need to check only is access to data base
View 1 RepliesI have a webform, that needs to check the values entered against a database, and then send an email if the request turns out positiv.
View 11 Repliesi have a Linq query that check something in database
after that i want to check if record find in database or not
dim re = From r in db.mytable _
where r.ID = _ID
Select r
how can i check the re return somthing or empty
I am trying to run the following SQL query
string strConString = ConfigurationSettings.AppSettings[ "conString" ];
myConnection = new OdbcConnection(strConString);
myConnection.Open(); // open connection
string strSelect= "select * from tbl_howells_product_data where title like" + "'" + strsearch + "%" +"'" + "order by product_id asc";
OdbcCommand myCommand = new OdbcCommand(strSelect, myConnection);
dtrReader=myCommand.ExecuteReader();
The problem is I need to check to see if any data has been returned from the SQL query, if there are no rows/ data returned by the query then I need to display a message to say that there aren't. I know that there isn't a 'number of rows method' for the dtrReader, so does anybody know how I could do this?
what is the best way to check today date come between from and To date. I am using below but it is taking too much time, but when i remove this condition it returns in 1 second.
getdate() BETWEEN a.ValidFrom AND COALESCE(a.ValidTo,getdate())
I have a multi- statement transcation in my stored procedure, that is either inserting or updating records in table1 and table2.
table1 has a check constraint. Will the check constraint be checked only after I call COMMIT in above transaction, OR will it be checked before I call COMMIT when using INSERT or UPDATE statement?
When it is bound to a datagrid. I do a grdELTCompletions.DataBind() and it shows that it's SELECTING, but returns nothing. I can execute the SP in MS SQL and it works fine. I just need know what elements of either the datasoure (sql to execute the SP) or the datagrid to find the error. Or even if there is a SQL log I can look at..
View 6 Repliesmy requirement is to update a duplicate record in datatable.in my website if anyone select a product more than one time then i have to check and update the quantity of that record.i use for loop for this but it is not working properly, it is running perfectly for one product but when i add another product it won't work.how can i do this?Here is my code part which is run on add button click
if (sc.dtcart.Rows.Count > 0)
{
for(int i=0;i<sc.dtcart.Rows.Count;i++)
[code]...
i have DateFrom and DateTo columns in tblLOgs.if they both are same then select only DateFrom else both selects.my procedure is ....do modification in them
[Code]....