using System;
using System.Collections.Generic;
using System.Web;
using System.Data.SqlClient;
using System.Data;
///
/// Summary description for database
///
public class database
{
public database()
{
//
// TODO: Add constructor logic here
//
}
public void insertNewBook(book newBook)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["localSqlServer"].ToString();
conn.Open();
SqlCommand cmd=new SqlCommand();
cmd.CommandType=System.Data.CommandType.StoredProcedure;
cmd.CommandText="insertNewBook";
SqlParameter bookID=new SqlParameter("@bookID",SqlDbType.BigInt);
bookID.Value=newBook.bookID;
cmd.Parameters.Add(bookID);
SqlParameter bookTitle=new SqlParameter("@bookTitle",SqlDbType.VarChar,100);
bookTitle.Value=newBook.bookTitle;
cmd.Parameters.Add(bookTitle);
SqlParameter bookAuthor=new SqlParameter("@bookAuthor",SqlDbType.VarChar,100);
bookAuthor.Value=newBook.bookAuthor;
cmd.Parameters.Add(bookAuthor);
SqlParameter bookImage=new SqlParameter("@bookImage",SqlDbType.Image);
bookImage.Value=newBook.bookImage;
cmd.Parameters.Add(bookImage);
cmd.Connection = conn;
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Close();
conn.Dispose();
}
No comments:
Post a Comment