Getting value of auto incremented column in advance - asp.net

I am using the entity framework in asp .net. In the database, I have a table named Post in which id is auto incremented. Now, before adding a new post, I want to know which id will be assigned to this post.

One way for you get your goal is use a SQL Server Procedure get max id from your table post and plus 1 and you will get you next Id.. this is a waste way for get your goal
SELECT MAX(ID) FROM POST
For how using store procedures into EF read this link maybe help you
http://www.devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values

Related

filling a grid with from two different record (table) sources

I was wondering if there is any way to populate a table using two different records. My records have the same primary keys, but when I am adding the specific fields to my grid I have this error:
More than one data (key) in one scroll.
I tried to make a Control view field in my primary record, and then refer the new record fields as relative fields but in this case the data is not populating in my grid. Any help or hint will be much appreciated.
I've only done this where the 2nd record is a Derived/Work record.
Can you create a view that combines both records, and put the view in the grid? FYI, peoplesoft let's you update the data in a view, which is not typical in an oracle db system.
Ok guys finally after all discussion, and much try rounds I figured out how to do this.
You need to add a draw a grid beside your old grid and populate it with a new record, which has dynamic view (dynamic sql). The only important case there, is you need to make sure the order of your fields in your records, are in the same order of your fields in the SELECT statement of your sql. Otherwise you will see
an SQL error
.
Try to make a field as display control field which is acting as primary key for its native table and as Foreign key for some other record.. A field needs to be made related if is being fetched from some other record... that is from the record which is not under current consideration. I think this way one can fetch data into grid or scroll respectively from multiple records.

unique client Reference id automatic generation Asp.net | Vb.net

My friends and I have started creating an e-commerce website using asp.net (vb.net). We are newbies and don't know much about it.
Can anybody show me how we can automatically generate unique reference id for each client who is purchasing the product from the website?
You can generate unique id's in database table by providing a column which will have a primary key or unique key assigned to it.and you can set auto increment property of that particular column on so it will increment automatically for each new customer entry.
You can also search the web in the mean time for better approach
There are a lot of ways and methods, but you can use the following command:
Dim user_id As Guid = Guid.NewGuid()
That will generate a unique Id for you.
You can also generate the new id automatically in your database table. Just make sure to create column with data type uniqueidentefier and assign it a default value property newid()

Whats the most efficient way to create an orchestration which updates an Oracle database?

I am creating my first orchestration in Biztalk and am having trouble coming up with an efficient way to update a database (specifically, up to 3 different tables).
The user calls our service with an inbound message matching a schema which contains emplid (unique id) and then a bunch of name-value pairs (see source schema in this picture). The "name" corresponds to a column in a table (e.g. if the name is "employeename" it corresponds to the NAME column of the EMPLOYEE table). The value of course is the new value that the user wants that column to be updated to.
So they could pass in an update message which only applies to 1 table, 2 tables, or all 3, depending on the fields they want to update for the passed in employee.
I am currently approaching it as 3 separate updates with 3 table adapters (one for each table, one of which is pictured above) but Im having trouble working with the different cases of if they pass in updateValuePairs for all 3 tables, versus only one or only for two tables (the other queries still attempt to run and fail). Am I approaching this right? Or is there a better way to accomplish what I am trying to do?
i would try i different way in order to implement cleaner solution,
create a Store-Procedure that handle the logic to which table to go
than you will need only on mapping and one LOB adapter instead of the 3 you got now
over view solution
1.receive input in the orchestration
2.mapping the input to the Stored procedure generated schema
3.sending the mapped data to the DB/LOB adapter into the DB
here is a link that can help you (im assuming you use biztalk 2010):
How to use Oracle Stored Procedure

Column Specific SqlCacheDependency in ASP.NET

I want to have a column specific SqlCacheDependency.
The Row Specific SqlCacheDependency is valid but i dont know how can i make Column Specific SqlCacheDependency
Example:
The query:
SELECT
[Extent1].[Price] AS [Price]
FROM [dbo].[Products] AS [Extent1]
where [Extent1].[ID] = 31167
causes the notification if the Row with ID = 31167 changes.
But the problem is that the Cache becomes invalid if any of the column of that row get changed but i want the cache becomes invalid only if Price of the ID 31167 get changed
I googled it for long but don't get any help.
Thanks
Any help is appreciated.
SqlDependency (which is used by SqlCacheDependency) does not offer column-level control. The semantics of the change notifications is that they are sent if a row returned or used by the query "might have changed."
If this is an important feature for you, you would need to implement it yourself, probably using triggers and either Service Broker to queue and deliver the change notifications, or through polling as with the old-style table-based notifications in .NET.
Another possibility might be to pull your columns of interest off into a separate table (either an explicit copy or one maintained with triggers) or a new table that you then join to the original one with views or SPs. Each row would then only contain the column you're interested in (plus the PK).

Beginning ASP.NET. using login name as sql parameter

Does anyone have some code or a link as to how to create the user login name as a parameter during a sql query in ASP.NET?
Basically I want to use the default membership structure with a new field ClubID, then I want to add a new table called aspnet_Clubs which contains things such as Club Name, stadium name, Balance etc etc... and then use a relationship between ClubID and a field in the aspnet_Clubs table to tie things together.
Then when each user logs in they should see the clubs information specific to their loginID.
I know the syntax to use for the query, its getting the loginname parameter and being able to use/assign it as part of the search that is causing me the problem.
In general it is not recommended to break the default schema of the aspnetdb where the Membership data is stored. It can bring you to unexpected consequences in the future.
I had a similar question a couple of days ago, please check it here, may be you will be able to adopt something from the discussion to your situation.

Resources