Click here to Skip to main content
15,892,005 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionImport Dynamic exel to sqlserver Pin
amina8928-Jun-10 4:43
amina8928-Jun-10 4:43 
AnswerRe: Import Dynamic exel to sqlserver Pin
T M Gray28-Jun-10 7:48
T M Gray28-Jun-10 7:48 
QuestionRe: Import Dynamic exel to sqlserver Pin
amina8928-Jun-10 22:34
amina8928-Jun-10 22:34 
AnswerRe: Import Dynamic exel to sqlserver Pin
T M Gray29-Jun-10 10:17
T M Gray29-Jun-10 10:17 
QuestionRe: Import Dynamic exel to sqlserver Pin
amina8929-Jun-10 23:50
amina8929-Jun-10 23:50 
Questionhow to paas a hidden link in a email Pin
raghvendrapanda28-Jun-10 3:53
raghvendrapanda28-Jun-10 3:53 
AnswerRe: how to paas a hidden link in a email Pin
David Mujica28-Jun-10 4:44
David Mujica28-Jun-10 4:44 
Questioninserting data to SQL via Storeprocedure(Please help) Pin
future383928-Jun-10 3:51
future383928-Jun-10 3:51 
Hello every1.

I am trying to improve my skill in ASP.net with C# code. I use MVC in this sample. I create a database and trying to insert data by using Storedprocedure. I created an SP in SQL and wana use it. the problem is I don't know how to use it. I write some code but I really don't know what is the next step. Could you please help me??



it is the first class:item


using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MvcApplication1.Models.Repository.DTO
{
public class Item
{
//definition of class's fileds
public int _id;
public int _code;
public string _description;
public string _creator;
public DateTime _created;


//definition of properties
public int Id
{
set
{
_id = value;
if (value < 0)
throw new ArgumentException(string.Format("Id should be greater than 0 !"));
}
get { return _id; }
}
public int Code
{
set { _code = value; }
get { return _code; }
}
public string Description
{
set { _description = value; }
get { return _description; }
}
public string Creator
{
set { _creator = value; }
get { return _creator; }
}
public DateTime Created
{
set { _created = value; }
get { return _created; }
}

//definiton of constructor
public Item(int id, int code, string description, string creator, DateTime created)
{
this._id = id;
this._code = code;
this._description = description;
this._creator = creator;
this._created = created;
}
}
}


the next class is as below

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using MvcApplication1.Models.Repository.DTO;

namespace MvcApplication1.Repository
{
public class ItemRepository
{
//definition of fields
private const string datasource =
"Data Source= Dell\\SQLEXPRESS;Initial Catalog=DB_Furniture.mdf;Integrated Security=True;User Instance=True";

private SqlConnection _connection;
private SqlDataAdapter _dataAdapter;
private DataSet _dataset;
private SqlCommand _sqlcommand;


//definition of constructor
public ItemRepository()
{

// instantiate the connection
_connection = new SqlConnection(datasource);

// instantiate a new DataSet
_dataset = new DataSet();
_dataAdapter = new SqlDataAdapter(_sqlcommand);


//definition of SQl SP parameters
_sqlcommand.CommandType = CommandType.StoredProcedure;
_sqlcommand.Parameters.Add("@Code", SqlDbType.NVarChar);
_sqlcommand.Parameters.Add("@Description", SqlDbType.NVarChar);
_sqlcommand.Parameters.Add("@Created", SqlDbType.NVarChar);
_sqlcommand.Parameters.Add("@Creator", SqlDbType.NVarChar);




what is next?????????????????????????????????????????????????????????????
how shold i call SP ?????








}
}
}



AnswerRe: inserting data to SQL via Storeprocedure(Please help) Pin
JHizzle28-Jun-10 3:57
JHizzle28-Jun-10 3:57 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
future383928-Jun-10 4:15
future383928-Jun-10 4:15 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
JHizzle28-Jun-10 4:39
JHizzle28-Jun-10 4:39 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
future383928-Jun-10 15:48
future383928-Jun-10 15:48 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
JHizzle28-Jun-10 21:14
JHizzle28-Jun-10 21:14 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
future383929-Jun-10 14:41
future383929-Jun-10 14:41 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
JHizzle29-Jun-10 22:19
JHizzle29-Jun-10 22:19 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
future383930-Jun-10 5:26
future383930-Jun-10 5:26 
GeneralRe: inserting data to SQL via Storeprocedure(Please help) Pin
JHizzle30-Jun-10 6:17
JHizzle30-Jun-10 6:17 
QuestionProblem getting EditCommand event to fire in nested DataGrid Pin
Phillip Donegan28-Jun-10 2:39
Phillip Donegan28-Jun-10 2:39 
AnswerRe: Problem getting EditCommand event to fire in nested DataGrid Pin
Phillip Donegan29-Jun-10 3:17
Phillip Donegan29-Jun-10 3:17 
QuestionJavascript Method call!! Pin
sabby200628-Jun-10 0:31
sabby200628-Jun-10 0:31 
AnswerRe: Javascript Method call!! Pin
Sandeep Mewara28-Jun-10 0:47
mveSandeep Mewara28-Jun-10 0:47 
AnswerRe: Javascript Method call!! Pin
Venkatesh Mookkan28-Jun-10 1:26
Venkatesh Mookkan28-Jun-10 1:26 
AnswerRe: Javascript Method call!! Pin
Not Active28-Jun-10 2:52
mentorNot Active28-Jun-10 2:52 
QuestionTextBox Readonly Property Pin
Anurag Gandhi27-Jun-10 22:36
professionalAnurag Gandhi27-Jun-10 22:36 
AnswerRe: TextBox Readonly Property Pin
JHizzle27-Jun-10 23:39
JHizzle27-Jun-10 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.