Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 05, 2010 05:05 AM by Wencui Qian - MSFT
Member
178 Points
382 Posts
Aug 03, 2010 03:16 PM|LINK
hi there, i have this procedure:
public void Search(int UserID) { SqlDataReader DR = null; SqlCommand cmd = new SqlCommand();//strsql, dbconn); cmd.Connection = Conn; cmd.CommandText = "UserSearch"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserID", UserID); if (Trans != null) { cmd.Transaction = Trans; } DR = cmd.ExecuteReader(); if (DR != null) { DR.Read(); MarketID = int.Parse(DR["MarketID"].ToString()); this.NetworkID = DR["NetworkID"].ToString(); this.ProfileID = int.Parse(DR["ProfileID"].ToString()); //this.RoleID = DR["RoleID"].ToString(); this.Email = DR["Email"].ToString(); this.NetworkDomain = DR["NetworkDomain"].ToString(); this.Name = DR["NameDesc"].ToString(); TypeID = int.Parse(DR["TypeID"].ToString()); locked = ToInt(DR,"locked"); } DR.Close(); }
All-Star
56784 Points
5796 Posts
Microsoft
Aug 05, 2010 05:05 AM|LINK
For your question, please check out these two posts:
http://msdn.microsoft.com/en-us/library/bb399357.aspx
http://www.hookedonlinq.com/CallingStoredProcedureUsingOptionalParameter.ashx
Thanks.
amodius
Member
178 Points
382 Posts
how can i convert my procedure with datareader to LINQ?
Aug 03, 2010 03:16 PM|LINK
hi there, i have this procedure:
public void Search(int UserID) { SqlDataReader DR = null; SqlCommand cmd = new SqlCommand();//strsql, dbconn); cmd.Connection = Conn; cmd.CommandText = "UserSearch"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserID", UserID); if (Trans != null) { cmd.Transaction = Trans; } DR = cmd.ExecuteReader(); if (DR != null) { DR.Read(); MarketID = int.Parse(DR["MarketID"].ToString()); this.NetworkID = DR["NetworkID"].ToString(); this.ProfileID = int.Parse(DR["ProfileID"].ToString()); //this.RoleID = DR["RoleID"].ToString(); this.Email = DR["Email"].ToString(); this.NetworkDomain = DR["NetworkDomain"].ToString(); this.Name = DR["NameDesc"].ToString(); TypeID = int.Parse(DR["TypeID"].ToString()); locked = ToInt(DR,"locked"); } DR.Close(); }the difficulties are the follows:
1)i cannot know how to execute stored procedure with LINQ
2)how can i set value to my properties after a selection?
3)how can i set optional parameters in a stored procedure by LINQ?
Wencui Qian ...
All-Star
56784 Points
5796 Posts
Microsoft
Re: how can i convert my procedure with datareader to LINQ?
Aug 05, 2010 05:05 AM|LINK
For your question, please check out these two posts:
http://msdn.microsoft.com/en-us/library/bb399357.aspx
http://www.hookedonlinq.com/CallingStoredProcedureUsingOptionalParameter.ashx
Thanks.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework