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

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

Select MessageID from inserted not working

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :Sql Server

I am trying to get the MessageID from the recently inserted row using the following table and stored proc. I am getting this error when I execute the SP:

(1 row(s) affected)
Msg 208, Level 16, State 1, Procedure GetNextResultMessageID, Line 8
Invalid object name 'inserted'.
(1 row(s) affected)

Is there another way I should be using the inserted table to get the MessageID for this row inserted?


    [MessageID ] [int] IDENTITY(1,1) NOT NULL,
    [MyMsg] [varchar](max) NULL,
    [MyName ] [varchar](50) NULL



USE [MyDb]


Create PROCEDURE [MySchema].[GetNextID]
@Myname varchar(50)

  Insert into MySchema.MyTable(MyMsg,MyName ) Values (' ',@Myname )
  Select MessageID from inserted

View Complete Post

More Related Resource Links

Select Top X not working

hello,ive a problem with ms access query; im trying to solect top X records and it fails returning > X each time. without the TOP keyword it would filter a lot more records, with TOP keyword it alwasy select more than required; im selecting 4 fields and performing value check on 3 of them, ive noticed that if i limit to different values of TOP it works in some cases while doesnt in others; it seems that it select TOP X records with specific value in the last field grouping the results until it select X records; here is an exaple:id     vi_se  ri_no  coeffaf418    16    27    0.592592592592593de788    18    31    0.580645161290323al452    22    38    0.578947368421053du771    14    25    0.56ns011    15    27    0.555555555555556iv729    15    27    0.555555555555556ge103    15    27    0.555555555555556in this case the effective records are 7 however if you group by coeff they are 5 as requested by the TOP keyword, this is the exact query result, there is no grouping performed on coeff field, in addition in this case the last three valu

Working on a SELECT Output

Hi Please can anyone help me. I've just joined two table together. Next I would like to output the SUM of one of the columns. I am almost a complete beginner so please could anyone give me some pointers on how to do this. Thank you Matthew

SQL Select Next 5 Working Days

Hi There, Is there any way that using SQL, you can return, in numeric's (1-31) - the numbers of the next 5 working days? I am trying to create a calendar, and I am struggling to get just working days in to my results. For example - if today is Thursday 15th Sept - the next 5 working numbers will be 15,16,19,20,21 Thanks Matt

Possible bug: Calendar views browse month function not working when list is inserted as webpart.


Inserted a custom list with a calendar view on a page as webpart. Browse month function does not work, there is a postback but month is still the current month instead of the next or previous.

Is this a know issue/bug?

Search working for only select users in same domain


I have encountered an issue where one user is able to conduct a search and retrive a full list of results but another user in the same domain and same membership group recieves no results at all.  Our environment is complex with several domains each trusting one another.  The SharePoint build is as follows:


2 Front End Servers with Loadbalance, 1 Application Server, 1 Index Server


So far I have tested with a user that cannot get results from a terminal client, desktop cleint and VPN remote access in all cases the user is unable to return results.   This user has accounts in 2 domains and when selecting to log on as a different user in the other domain results are returned.  I beleived then that it had to be an account issue in the other domain.  However when I worked with another user who also has accounts in both domains that user was not able to return results with either account.  So I am not sure it is domain account related.


I setup a dev box in the domain and made it bare bones with no load balancer, however when I add the user account who was having issue and a search is run no results are returned. 


The search database appears fine and healty and data is populating the tables

Stored Procedure Metadata failure- Dummy select not working


I have a procedure that involves creation of temp table, inserting data into it and use this data to populate another table variable whose output forms the dataset for the OLE DB Source.

Here is the general outlay of the procedure (just a sample data) -


IF 1=0


sql select query not working


hi guys,

i have been having trouble trying to find out what is wrong with my sql select query... i wanted to select a sessionID by comparing the tourID and dates. the dates datatype at the database is datetime and the value of itemSessionDate is in string. i tried to convert itemSessionDate to date and dateAndTime but it gave me mm/dd/yyyy while the date in my database is dd/mm/yyyy hh:mm:ss. so i thought i can try using the itemSessionDate string as it has the same value as the one return from the database. but it keeps on goin to the if not reader.hasRows and quit the statement

could somebody teach me how to solve this problem....

below are my code

Private Function getItemSessionID(ByVal tourID As String, ByVal itemSessionDate As String)
        Dim sessionID As String = ""

        Dim strConn As String = ConfigurationManager.ConnectionStrings("ProrsumDBConnectionString").ConnectionString
        'create sql connection
        Dim myConn As New SqlConnection(strConn)
        'Open connection; Note: You need to open a connection to database

            Dim cmd As String = "SELECT sessionID " & _
                                " FROM TourSession " & _
                                " WHERE tourID=" & Integer.Pars

Sharepoint SPDatasource select command where clause not working for some columns



       I'm using MOSS 2007. I'm using spdatasource to bind a custom list to gridview using webuser control(webpart). spdatasource select command working for all columns except the status column. my status column is a choice- radio with the following options. Pending Review, Checked and Approved. I have checked the field internal name, every thing is correct, but only for status column filtering not happening. Gridview coming as blank

i tried using 

             <FieldRef Name='Status'/>
             <Value Type='Choice'>Pending Review</Value>

Any idea?????




SP Datasource select Command not working for Status Column



    (MOSS 2007-Webuser control Web part)

    I'm having a cutom list that i'm binding using SPDatasource to a gridview. I want to filter the list based on column values. I tried the following code

            SPList taskList = site.Lists["Accounts"];
            SPDataSource mySPDS = new SPDataSource();

         mySPDS.SelectCommand = "<View><Query><Where><Eq><FieldRef Name='Vendor_x0020_Name'/><Value Type='Text'>"+ddlVendorName.SelectedItem.Text +"</Value></Eq></Where></Query></View>";


mySPDS.SelectCommand = "<View><Query><Where><Eq><FieldRef Name='Status'/><Value Type='Choice'>" + ddlStatus.SelectedItem.Text + "</Value></Eq></Where></Query></Vi

Working with SharePoint document libraries

Document libraries are collections of files that you can share with team members on a Web based on Microsoft Windows SharePoint Services. For example, you can create a library of common documents for a project, and team members can use their Web browsers to find the files, read them, and make comments. Users with Microsoft Office 2003 can check out and edit the files as if they resided on a local or network drive.

By default, your team Web site comes with a built-in document library named Shared Documents, which is listed on the Quick Launch bar as well as on the Documents and Lists page.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Row command working on all rows not selected one?



I have this code that hides a column in a gridview.  (The column houses another nested gridview).

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Select" Then
            If GridView1.Columns(0).Visible = False Then
                GridView1.Columns(0).Visible = True
                GridView1.Columns(0).Visible = False
            End If
        End If
    End Sub

The trouble is that if I click the select link on one row that action to hide is carried out on all rows.  How can I set this up so that it only hides the row that is selected?


Select value in gridview


Hi, I am new to gridview. I want to make a gridview. Its row when selected should direct me to a specific .aspx page.Each row should direct to a different page. Should I use querystrings for this? Please suggest. Regards, ap.

upload file not working



iam using masterpage and ajax update panel, i have child page called  fileupload.aspx,i try to upload the file

but its not working , can i use updatepanel in child page , pls very urgent

looking forward for answer.

JQuery Treeview plugin is not working with Ajax page load in ie8


Hi there,

I developed a page where i m using jquery treeview plugin to generate tree. It worked fine on FF, IE8 with out ajax.

But when my page loads thro' ajax call in IE8, it is not collapsing or expanding tree.

Any idea?

Thanks in advance.

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