15,669,304 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 12385326 (Top 95 by date)
Member 12385326
4-Aug-16 4:35am
View
please provide solution for half year also
Member 12385326
4-Aug-16 4:34am
View
Thanks a lot. it works
Member 12385326
4-Aug-16 4:20am
View
@OriginalGriff please suggest how to set this value for datetimepicker.
I have 2 datetimpicker. o the valueChanged Eent of fisrt second displays the quarter date
Member 12385326
4-Aug-16 4:01am
View
it should be in date only.i mean if I select start date=2013-07-01 then end date=2013-09-30 like this.
Member 12385326
16-Jul-16 6:39am
View
i got the solution:
public void PrintRow()
{
int x = 20; int y = 50, m = 20, n = 50;
panel2.Controls.Add(new Label { Text = "Payment Type:" + cmb_AddPayment_Payment.Text, Height = 20, Width = 150, Name = "lable" + i, BackColor = Color.Transparent, Location = new Point(x + i, y * i) });
panel2.Controls.Add(new Label { Text = "Amount Paid:" + txt_AddPayment_AmountPaid.Text, Height = 20, Width = 150, Name = "Text" + i, BackColor = Color.Transparent, Location = new Point(x + i + 180, y * i) });
panel2.Controls.Add(new Label { Text = "Date" + dateTimePicker1.Text, Height = 20, Width = 150, Name = "Text" + i, BackColor = Color.Transparent, Location = new Point(x + i + 350, y * i) });
panel2.Controls.Add(new Label { Text = "Notes:" + txtNotes.Text, Height = 20, Width = 400, Name = "Text" + i, BackColor = Color.Transparent, Location = new Point(x + i + 500, y * i) });
// y += 30;
i++;
}
i am calling this on button click.also i have added scrollbar to may panel
its working but after particular point distance between row gets increases. any suggession
Member 12385326
16-Jul-16 3:58am
View
@Gegniani Yes u got my point.but i want c# code :(
Member 12385326
15-Jul-16 8:01am
View
i have 5 textboxes. and 1 button.
on button click i am copying textboxes value to Label.
but i am generating Label through code.
on fisrt click i am copying data fron textbox to label.and all the label should be in one line(like row)
on sencond click again same operation but all the labels in next line(i.e like second row)
like wise as many click i perform 5 label should display in line(like row in table)
Member 12385326
11-Jul-16 6:02am
View
Iw@zi?? not getting u.
Member 12385326
11-Jul-16 4:06am
View
there is a option on reportviewer to export it as "pdf","word","excel" .
but after saving i want to search it by entering number in textbox.
how i should do that ?
Member 12385326
8-Jul-16 4:57am
View
any format..but i want to open it late for viewing purpose according to particular id.
Member 12385326
23-Jun-16 6:33am
View
i used textChanged event ..it is working fine for me :)
Member 12385326
14-Jun-16 4:33am
View
just got value for Purid=2 :) but vendAcc=null :(
Member 12385326
14-Jun-16 4:21am
View
where i need to focus then javascript or method in controller??
Member 12385326
14-Jun-16 4:11am
View
nope.it is showing Purid=0
Member 12385326
14-Jun-16 3:57am
View
yes it is there in table. id which i am passing through method as a parameter i.e PurId it is showing 0
Member 12385326
14-Jun-16 3:41am
View
no. i am getting null.just checked :(
Member 12385326
14-Jun-16 1:15am
View
Deleted
yes it is also working fine if i use ado.net entity model. but is is not working if i use code first from database option of data model though it is generating model view controller directly from database.
i tried alot.still not getting
Member 12385326
13-Jun-16 9:03am
View
Deleted
i tried.there is no problem in controller. i am getting proper id from controller into javascript in alert box.problem starts from success function.
Member 12385326
1-Jun-16 5:59am
View
is it poosible to generate entity framwork data model through code without using wizard?
Member 12385326
26-May-16 7:51am
View
yes sure
Member 12385326
26-May-16 7:47am
View
Deleted
@karthik hey i got proper op..thnx a lot for ur valuable time.
i did this:
$("#CustomerName").val(response.Customer_Name)+""+$("#Address").val(response.Billing_Address);
Member 12385326
26-May-16 7:44am
View
Deleted
name is correct. but i when i hide one textbox like this
//$("#CustomerName").val(response.Customer_Name);
$("#Address").val(response.Billing_Address);
it is respective value in another textbox.
means at a time it is showing only one textbox value
Member 12385326
26-May-16 7:37am
View
Deleted
@KARTHIK..hey fixed it..and it is showing related data in 1 textbox.but not in other textbox
Member 12385326
26-May-16 7:25am
View
it is showing count=0 :(
Member 12385326
26-May-16 7:16am
View
Deleted
yes it is present.
Member 12385326
26-May-16 7:12am
View
Deleted
@karthik hey i got int inputid=2 i.e orrect value.
but for
var item = acc.tbl_CustomerCreation.FirstOrDefault(k => k.Account_No== inputid);
i am getting null value
Member 12385326
26-May-16 6:40am
View
Deleted
i am not getting dropdownValue in Method of controller.
there are two items in db.yes id passed from ajax mached with item in db table.
Member 12385326
26-May-16 5:51am
View
Deleted
no i have values in database. and that value (Account_No) i am populating in dropdownlist. i am not getting respective values in textboxes.
yes i am getting inputid null
Member 12385326
26-May-16 5:48am
View
Deleted
@karthik i got error for this new script
parsererror syntaxerror: unexpected end of JSON input [object object]
Member 12385326
26-May-16 5:42am
View
Deleted
i am getting item as null while debugging
Member 12385326
26-May-16 5:37am
View
Deleted
i tried that only
method:
public ActionResult GetValuesFromDatabase(string inputId)
{
int inputid = Convert.ToInt32(inputId);
using (AccountDBEntities3 acc = new AccountDBEntities3())
{
var item = acc.tbl_CustomerCreation.FirstOrDefault(k => k.Account_No == inputid);
if (item != null)
return Json(item);
else
return null;
}
}
script:
<script>
function copyValue1() {
debugger;
var inputID = $("#SalesOrderAccNoDropDown1").val();
$.ajax({
type:'GET',
url: '/Quotation/GetValuesFromDatabase',//Change the function name with your actual function name
datatype: 'application/json',
contentType: 'application/json',
//data: { inputid: $("#SalesOrderAccNoDropDown1").val() },
data: JSON.stringify({ inputID: +inputID }),
success: function(response) {
//assign values to your textboxes.
$("#CustomerName").val(response.Customer_Name);
$("#Address").val(response.Biliing_Address);
alert(inputID)
alert(response.Biliing_Address)
},
error: function(){alert("Whooaaa! Something went wrong..")},
});
}
</script>
Member 12385326
26-May-16 5:18am
View
Deleted
@karthik i debuged that method..it is not allowing to enter below this line
using (AccountDBEntities3 acc = new AccountDBEntities3())
and also i put alert in my script to chek whether it is taking value or not..
i am getting value of inputID by this alert
alert(inputID)
but i am getting "undefined" by this alert
alert(response.Biliing_Address)
Member 12385326
26-May-16 4:20am
View
okk..i'll let u know
Member 12385326
26-May-16 4:12am
View
@karthik still it is not working :(
Member 12385326
26-May-16 2:07am
View
Deleted
see KARTHIK this is my method in controller:
public JsonResult GetValuesFromDatabase(string inputId)
{
// int inputid = Convert.ToInt32(inputId);
using (AccountDBEntities2 acc = new AccountDBEntities2())
{
var firstValue = from c in acc.tbl_CustomerCreation where c.Account_No==inputId
select c.Customer_Name ; //Get this from database;
var secondValue = from c in acc.tbl_CustomerCreation
where c.Account_No == inputId
select c.Billing_Address; ; //Get this from database;
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
string result = javaScriptSerializer.Serialize(firstValue);
string result1 = javaScriptSerializer.Serialize(secondValue);
return Json(result,result1, JsonRequestBehavior.AllowGet);
}
}
this is my script in view:
<script>
function copyValue1(){
$.ajax({
type: "GET",
url: "/Quotation/GetValuesFromDatabase",//Change the function name with your actual function name
dataType: "Json",
data: { inputId: $("#SalesOrderAccNoDropDown1").val() },
success: function(response) {
//assign values to your textboxes.
$("#CustomerName").val(response.result);
$("#Address").val(response.result1);
}
});
}
</script>
this is my dropdown and textboxes in view:
@Html.DropDownList("Acc_No", (IEnumerable<SelectListItem>)ViewBag.Acc_No, "select UnderGroup", new { @class = "form-control", @id = "SalesOrderAccNoDropDown1", @onchange = "copyValue1()" })
textboxes:
<tr>
<td>
@Html.LabelFor(model => model.CustomerName, htmlAttributes: new { @class = "control-label col-md-2" })
</td>
<td>
@Html.EditorFor(model => model.CustomerName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CustomerName, "", new { @class = "text-danger" })
</td>
<td>
@Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" })
</td>
<td>
@Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" })
</td>
</tr>
it is not throwing error but not giving expected op also.
Member 12385326
26-May-16 1:43am
View
Deleted
in that query only i m confused.also it is throwing error for value1 and value 2.what can be its datatype?
Member 12385326
26-May-16 1:24am
View
Deleted
i tried this as suggested before onthis site but am confused over method in controller.we are passing inuptID in method parameter but i am not able to write query for Firstvalue and SecondValue in controller.plz guid me on this.
this is method in controller:
public JsonResult GetValuesFromDatabase(int inputId){
//Perform database query here and assign that value to the variables to be returned.
var firstValue = "Value for TextBox1"; //Get this from database;
var secondValue = "Value for TextBox2"; //Get this from database;
var jsonData = new
{
value1: firstValue,
value2: secondValue
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
and this is scrip in View:
function copyValue1(){
$.ajax({
type: "GET",
url: "/YourControllerName/GetValuesFromDatabase",//Change the function name with your actual function name
dataType: "Json",
data: { inputId: $("#YourDropdownList").val()},
success: function (response) {
//assign values to your textboxes.
$("#Textbox1").val(response.value1);
$("#Textbox2").val(response.value1);
}
});
}
Member 12385326
12-May-16 2:02am
View
@zafar sultan thnx for your help.can you give me example of database query.i mean how to write it in mvc.where you have written "value for textbox1" and "value for textbox2"
Member 12385326
7-May-16 6:32am
View
cshtml file. and its runtime error when i try to submit data into database
Member 12385326
7-May-16 6:24am
View
i am getting error for this dropdown i.e."UnderGroup" in model when i am trying to insert data nto db
<select class="form-control" id="PrimaryGroupDropDown1" >
<option>---Select PrimaryGroup---</option>
@foreach (var item in ViewBag.ItemGroupList)
{
<option value="@item.ItemGroup_Id">@item.Group_Name</option>
}
</select>
Member 12385326
7-May-16 6:22am
View
this is my model:
public class ItemModel
{
public string ItemGroup { get; set; }
public string GroupNature { get; set; }
public IEnumerable<SelectListItem> UnderGroup { get; set; }
// public string UnderGroup { get; set; }
}
this is my repository folder in which i have called stored procedure :
public class ItemRepository
{
private SqlConnection con;
private void connection()
{
string constr = ConfigurationManager.ConnectionStrings["con"].ToString();
con = new SqlConnection(constr);
}
public bool ItemGroup(ItemModel ig)
{
string abc = "insert";
connection();
SqlCommand com = new SqlCommand("spr_ItemGroup1", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@abc", abc);
com.Parameters.AddWithValue("@Group_Name", ig.ItemGroup);
com.Parameters.AddWithValue("@Primary_Gr", ig.GroupNature);
com.Parameters.AddWithValue("@Under_Gr", ig.UnderGroup);
con.Open();
int i = com.ExecuteNonQuery();
con.Close();
if (i >= 1)
{
return true;
}
else
{
return false;
}
}
Member 12385326
7-May-16 6:09am
View
this is my view for dropdown
<td>
<select class="form-control" id="PrimaryGroupDropDown1" >
<option>---Select PrimaryGroup---</option>
@foreach (var item in ViewBag.ItemGroupList)
{
<text>
<option value="@item.ItemGroup_Id">@item.Group_Name</option>
}
</select>
</td>
and this is my controller code for this dropdown
public ActionResult Item()
{
ItemModel Au = new ItemModel();
using (AccountDBEntities5 AccountDBEntities = new AccountDBEntities5())
{
ViewBag.ItemGroupList = AccountDBEntities.tbl_ItemGroup.ToList();
}
return View(Au);
}
i am trying to insert data from dropdown to database.but while submiting it is throwing error.
is there any solution?
Member 12385326
29-Apr-16 7:55am
View
Deleted
i have this code in my controller. m i doing right?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MathuraApp.Repository;
using MathuraApp.Models;
namespace MathuraApp.Controllers
{
public class CurrencyCreationController : Controller
{
// GET: CurrencyCreation
public ActionResult Converter()
{
return PartialView();
}
public ActionResult currency()
{
return PartialView();
}
[HttpPost]
public ActionResult currency(CurrencyCreationModel ccm)
{
try
{
if (ModelState.IsValid)
{
CurrCreRep ccr = new CurrCreRep();
if (ccr.Currency(ccm))
{
ViewBag.Message = "Currency details added successfully";
}
}
return PartialView(ccm);
}
catch
{
return PartialView(ccm);
}
}
public ActionResult Converter(CurrencyCreationModel ccm)
{
try
{
if (ModelState.IsValid)
{
CurrCreRep ccro = new CurrCreRep();
if (ccro.Converter(ccm))
{
ViewBag.Message = "Currency details added successfully";
}
}
return PartialView(ccm);
}
catch
{
return PartialView(ccm);
}
}
}
}
and i have doubt onn this line in my view :
<div class="tab-pane active " id="tab_1_2">
@using (Html.BeginForm("Converter", "CurrencyCreationController", FormMethod.Get,new { }))
{
and
<div class="tab-pane " id="tab_1_1">
@using (Html.BeginForm("currency", "CurrencyCreationController", FormMethod.Get,new{ }))
the code is working partially..i mean i can insert only one tab's data in database.i want both the tab should be working
Member 12385326
29-Apr-16 4:19am
View
Deleted
i want to create 3 tabs in my asp.net web page. i am using mvc. how to create it i mean how many controller,models and view i need to create. i tried with one model,controller and view. in my view there is design for tabs. but when i run it ,it is not inserting data of second tab;it is inserting data of first tab only. though i have procedure in backend.that i am calling from frontend.
Member 12385326
29-Apr-16 2:48am
View
what is the requirement for multiple tabs on single page in asp.net mvc. my question typed wrongly.n please refer above details for this imporved question
Member 12385326
26-Apr-16 1:17am
View
i have menu "sales order" .when user clicks on that he should see sales order page with voucher_no generated on it automatically. then he will fill the details and will click on submit button
Member 12385326
25-Apr-16 9:01am
View
when we submit that time only it displays voucher_no. user should get to see voucher_no as soon as he opens the web page
Member 12385326
25-Apr-16 8:52am
View
becasue i want voucher_no should get generate when we open webpage. if i write it inside button click then it displays voucher_no when we submit our data
Member 12385326
25-Apr-16 8:42am
View
i wrote inside if(!page.ispostback) only.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Filltxt();
}
}
void filltxt()
{
string strcon = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ToString();
String insert, AccountNumber, VoucherNumber,VendorName, Address, PurchaseTaxType, Date, StoreName, Currency;
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlCommand com = new SqlCommand("spr_PurchaseRegister", con);
insert = "insert";
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@abc", insert);
SqlParameter p1 = new SqlParameter("@Voucher_No", SqlDbType.VarChar, 50);
p1.Direction = ParameterDirection.Output;
com.ExecuteNonQuery();
con.Close();
string voucherNumber = p1.Value.ToString();
txtVoucherNo1.Value = voucherNumber;
lblPurchaseRegister.Text = "registered successfully";
}
Member 12385326
25-Apr-16 7:12am
View
again i am in trouble. the code u suggested is working fine. but i want that voucher_no should be generated when page is loaded. and should get submited when on button clicked. i tried this by writing it in page_load but it is inserting data twice or sometimes it is null :(
Member 12385326
25-Apr-16 4:46am
View
i used textboxname.value :) thnx a lot for ur help
Member 12385326
25-Apr-16 4:43am
View
i tried this. but it is not suggesting text property.
Member 12385326
25-Apr-16 4:38am
View
thnx for ur help.the code is working if i take lable to display it. but i am taking textbox. and it is not showing text property.what to do?
Member 12385326
25-Apr-16 4:20am
View
void Filltxt()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select voucher_No from tbl_PurchaseRegister", con);
SqlDataReader dap = cmd.ExecuteReader();
while (dap.Read())
{
txtVoucherNo1.Value= dap.GetValue(0).ToString();
}
i guess am making here small mistake.because it is retriving last inserted voucher no from database and displaying it in my asp.net form.an u please help me out
Member 12385326
25-Apr-16 3:55am
View
This is my stored procedure:
ALTER proc [dbo].[spr_SalesOrder]
(
--@SalesOrder_Id int =null,
@Voucher_No varchar(50)=null,
@Account_No varchar(50)=null,
@Customer_Name varchar(50)=null,
@Address varchar(50)=null,
@PurchaesTax_Type varchar(50)=null,
@Date varchar(50)=null,
@Store_Name varchar(50)=null,
@Currency varchar(50)=null,
@abc varchar(20) =null
)
AS
BEGIN
BEGIN
set nocount on;
DECLARE @SalesOrder_Id int
IF @abc='insert'
insert into tbl_PurchaseRegister(Account_No,customer_Name,Address,SalesTax_Type,Date,Store_Name,Currency)
Values(@Account_No,@Customer_Name,@Address,@SalesTax_Type,@Date,@Store_Name,@Currency)
SET @SalesOrder_Id = SCOPE_IDENTITY();
END
END
select * from tbl_SalesOrder
Member 12385326
25-Apr-16 3:51am
View
yes it is computed column.it is computing S01,S02....... like this.
Member 12385326
25-Apr-16 3:48am
View
protected void btnSubmit_Click(object sender, EventArgs e)
{
string strcon = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ToString();
String insert, VoucherNumber, AccountNumber, CustomerName, Address, SalesTaxType, Date, StoreName, Currency;
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlCommand com = new SqlCommand("spr_SalesOrder", con);
VoucherNumber = txtVoucherNo1.Value.ToString();
SqlParameter p1 = new SqlParameter("Voucher_No", VoucherNumber);
com.Parameters.Add(p1).Direction=ParameterDirection.Output;
com.ExecuteNonQuery();
con.Close();
lblSaleOrder.Text = "Registered Successfully";
Member 12385326
25-Apr-16 2:47am
View
it is not displaying autogenerated voucher_no from backend to front end
Member 12385326
12-Apr-16 8:58am
View
my fruits and flower are not linked to each other.and join is giving me all the rows. i have dropdownlist in main_table,to select data from other two table.
Member 12385326
6-Apr-16 6:51am
View
Deleted
i want some data from another table into main table.
like i said i have 3 tables. and i m trying to insert data from "table 2 and table 3" he into "table 1". in table 1 i have dropdownlist for the data from another table.
i.e group_name & undergroup(from table 2) for this i have dropdown list in table 1(itemcreation)
same for unit table.
INSERT INTO tbl_ItemCreation
SELECT @Item_Name,@Item_Code,t1.ItemGroup_Id,t1.UnderGroup,t1.Group_Name ,t2.Unit_Id
FROM tbl_ItemGroup t1,tbl_UnitCreation t2 where UnderGroup=@UnderGroup
and i have condition
for eg: group name='nokia'
undergroup='mobile'
i want group_name on the selection of undergroup in table 1
Member 12385326
6-Apr-16 6:26am
View
Deleted
this is my itemgroup prcedure for insert:
USE [AccountDB]
GO
/****** Object: StoredProcedure [dbo].[spr_ItemGroup] Script Date: 4/6/2016 3:51:15 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spr_ItemGroup]
@Group_Name varchar(50)=null,
@Chbox_Val varchar(50)=null,
@UnderGroup varchar(50)=null,
@Comments varchar(50)=null,
--@flag varchar(50)=null,
@abc varchar(50)=null
AS
BEGIN
set nocount on;
DECLARE @ItemGroup_id int
IF ((SELECT COUNT(Group_Name ) FROM tbl_ItemGroup WHERE Group_Name = @Group_Name
GROUP BY Group_Name) > 0)
begin
SET @ItemGroup_id = NULL
print 'Item Exists'
end
else
begin
IF @abc='insert' and @Chbox_Val='yes'
begin
insert into tbl_ItemGroup(Group_Name,Chbox_Val ,UnderGroup,Comments )
values(@Group_name,@Chbox_Val,'',@Comments)
set @ItemGroup_id= SCOPE_IDENTITY();
print 'block1'
end
else if @abc='insert' and @Chbox_Val='no'
begin
print 'block3'
insert into tbl_ItemGroup select @Group_name,'no',[Group_Name],@Comments from tbl_ItemGroup where Group_Name=@UnderGroup and Chbox_Val='yes'
set @ItemGroup_id= SCOPE_IDENTITY();
end
end
end
this is my unit procedure for insert":
USE [AccountDB]
GO
/****** Object: StoredProcedure [dbo].[spr_UnitCreation] Script Date: 4/6/2016 3:52:35 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[spr_UnitCreation]
@Unit_Name varchar(50)=null,
@Unit_Abbreviation varchar(50)=null,
@Unit_type varchar(50)=null,
@Decimal_Places varchar(50)=null,
@Description varchar(50)=null,
@Super_Unit varchar(50)=null,
@Per_Unit varchar(50)=null,
--@Unit_Id int output,
@abc varchar(50)=null
As
begin
if @@ROWCOUNT=0
begin
if @abc='insert' and @Unit_Type='Single'
begin
set nocount on;
DECLARE @Unit_Id int
insert into tbl_unitCreation (Unit_Name,Unit_Abbreviation,Unit_type,
Decimal_Places,Description,Super_Unit,Per_Unit )values (@Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,@Super_Unit,@Per_Unit )
set @Unit_Id=scope_identity();
end
if @abc='insert' and @Unit_Type='Compound'
insert into tbl_unitCreation select @Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,[Unit_Name],@Per_Unit
from tbl_UnitCreation where Unit_Name=@Super_Unit and Unit_Type='Single'
set @Unit_Id=scope_identity();
end
end
select * from tbl_UnitCreation
both are working fine.
now i want third procedure for my itemcreation table.which will fetch values of group name and undergroup from itemgroup table and unit name from unit table.
and this is my query for insert in itemcreation
INSERT INTO tbl_ItemCreation
SELECT @Item_Name,@Item_Code,t1.ItemGroup_Id,t1.UnderGroup,t1.Group_Name ,t2.Unit_Id
FROM tbl_ItemGroup t1,tbl_UnitCreation t2 where UnderGroup=@UnderGroup and Group_Name=(select Group_Name from tbl_ItemGroup where Chbox_Val='no' and @UnderGroup in (select under from @data ))
Member 12385326
6-Apr-16 5:48am
View
Deleted
INSERT INTO tbl_ItemCreation
SELECT @Item_Name,@Item_Code,t1.Group_Name,t1.underGroup ,t2.Unit_Id,t1.ItemGroup_Id
FROM tbl_ItemGroup t1,tbl_UnitCreation t2 where Group_Name=@Group_Name and UnderGroup=(select Group_Name from tbl_ItemGroup where Chbox_Val='no' and @Group_Name=Group_Name)
i tried this.because join is not the thing i was wanted.i dont simply want to join tables. i want to fetch record from another two table into first table on the selection of respective value
Member 12385326
4-Apr-16 8:32am
View
Deleted
yeah the code u posted above is error free..but not giving expected result.
i should use foreign key or not?i mean i am confused over which column should be there in table 1 i.e itemcreation.to get data from another table.column name or its primary key?
Member 12385326
31-Mar-16 7:16am
View
thnks a lot for your help
Member 12385326
31-Mar-16 7:15am
View
sorry.i was my mistake.code is working the mistake was in where condition "@undergroup" should be "undergroup". so when i select that table i got all the values also it is working in if condition also
Member 12385326
31-Mar-16 7:04am
View
it is "begin" "As begin " which is below As when we start procedure.
also this code is not working when i tried to get values in table
declare @UnderGroup varchar(50)
DECLARE @data TABLE (under VARCHAR(100));
INSERT INTO @data
select Group_Name
from tbl_AccountGroup
where @UnderGroup='Sales A/C'
select under from @data
Member 12385326
31-Mar-16 6:50am
View
ASBEGIN
declare @UnderGroup varchar(50)
DECLARE @data TABLE (under VARCHAR(100));
INSERT INTO @data
select Group_Name
from tbl_AccountGroup
where @UnderGroup='Sales A/C'
begin
IF @abc='insert' and ( @Group_Name='Sales A/c' or @Group_Name IN (SELECT under FROM @data ))
BEGIN
--print 'block executed'
set nocount on;
--set @under=(select Group_Name from tbl_AccountGroup where UnderGroup='Sales A/C' group by Group_Name)
DECLARE @Customer_Id int
--declare @Group_Id int
insert into tbl_CustomerCreation select [Group_Id],@Customer_Name,@Account_No,@Email,
@Billing_Address,@Shipping_Address,@Phone_No,@Fax,@Date,@OB,@Nature1,@CB,@Nature2,@Description from
tbl_AccountGroup WHERE Group_Name =@Group_Name
SET @Customer_Id= SCOPE_IDENTITY();
END
see it is like this
Member 12385326
31-Mar-16 6:44am
View
i have not posted my all code. @abc is variable which is i m using to execute my procedure.if it is @abc='insert' then it will execute insert code.like this i have update,select,delete assigned to @abc .though i am combining insert update.....in one procedure only.and i have "brgin" below my if statement also.
Group names are the names which i am fetching from another table.in that table also i have two columns "group name" and "undergroup"
firstly we add group name by selecting checkbox as it is primary group.for eg. "group name=sales a/c" then on next insert checkbox is unchecked and we add undergroup which is under group name. for eg. "group name=sales 1 and undergroup=sales a/c"
Member 12385326
31-Mar-16 6:30am
View
Deleted
DECLARE @data TABLE (under VARCHAR(100));
INSERT INTO @data
select Group_Name
from tbl_AccountGroup
where @UnderGroup='Sales A/C'
begin
IF @abc='insert' and (@Group_Name='Sales A/c' or @Group_Name IN (SELECT under FROM @data ))
i tried this.
but still is not working
Member 12385326
31-Mar-16 5:44am
View
yes. you are write.because i that query is returning more than one value thats why i am getting this error.i just checked
Member 12385326
31-Mar-16 5:43am
View
no. suppose Sales A/c is my main group i can have sales1,sals2,sale3
accounts under Sales A/c.they will never ever same.
Member 12385326
31-Mar-16 5:39am
View
is there any other solution i can implement other than than "or"
Member 12385326
31-Mar-16 5:34am
View
it depends on us..how many we are adding.
Member 12385326
31-Mar-16 5:24am
View
it is returning group names which are under Sales A/C group
Member 12385326
31-Mar-16 5:21am
View
i am checking that grp name multiple times with different if elseif statements.thats why i created that permanent lookup table.
Member 12385326
31-Mar-16 4:30am
View
but i am using this data like this
IF @abc='insert' and @Chbox_Val='p' and @Group_Name IN (SELECT grp FROM @data)
begin
insert into tbl_AccountGroup(Group_Name,Chbox_Val ,UnderGroup,Comments,flag )
values(@Group_name,@Chbox_Val,@UnderGroup,@Comments,'1')
set @Group_id= SCOPE_IDENTITY();
print 'block1'
end
for this i need to store this values in list kind of thing..so used this table.am i going write or wrong?
Member 12385326
31-Mar-16 4:20am
View
i am not getting it..can you show it with my example?
Member 12385326
31-Mar-16 4:19am
View
Deleted
i am not getting it..can you show it with my example?
Member 12385326
25-Mar-16 1:22am
View
can you provide example of login? and what is better way to do this? trigger,cursor or stored procedure?
Member 12385326
23-Mar-16 1:01am
View
i want to write stored procedure for my tables.and in one procedure i want to insert ,update ,select and delete.what is the better way to do that
Member 12385326
22-Mar-16 8:21am
View
so what i have to do? should i remove my scope_identity from insert procedure?
but i also want to set scope_identity :(
Member 12385326
22-Mar-16 8:15am
View
i have changed my code.still it is not working with update .
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[spr_unitCreation]
@Unit_Name varchar(50)=null,
@Unit_Abbreviation varchar(50)=null,
@Unit_type varchar(50)=null,
@Decimal_Places varchar(50)=null,
@Description varchar(50)=null,
@Super_Unit varchar(50)=null,
@Per_Unit varchar(50)=null,
--@Unit_Id int output,
@abc varchar(50)=null
As
begin
if @abc='insert' and @Unit_Type='Single'
begin
set nocount on;
DECLARE @Unit_Id int
insert into tbl_unitCreation (Unit_Name,Unit_Abbreviation,Unit_type,
Decimal_Places,Description,Super_Unit,Per_Unit )values (@Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,@Super_Unit,@Per_Unit )
set @Unit_Id=scope_identity();
end
if @abc='insert' and @Unit_Type='Compound'
insert into tbl_unitCreation select @Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,[Unit_Name],@Per_Unit
from tbl_UnitCreation where Unit_Name=@Super_Unit and Unit_Type='Single'
set @Unit_Id=scope_identity();
--SET NOCOUNT OFF
if @abc='update'
begin
set nocount on;
SELECT SCOPE_IDENTITY() AS unit_Id
--SET @unit_Id = CAST(SCOPE_IDENTITY() AS INT)
--declare @Unit_Id int
DECLARE @newId INT
SELECT @newID = SCOPE_IDENTITY()
update tbl_unitCreation set Unit_Name=@Unit_Name,Unit_Abbreviation=@Unit_Abbreviation,Unit_type=@Unit_type,
Decimal_Places=@Decimal_Places,Description=@Description,Super_Unit=@Super_Unit,Per_Unit=@Per_Unit
where Unit_Id =@newID
--
--SET NOCOUNT OFF
end
end
select * from tbl_UnitCreation
--delete from tbl_UnitCreation where Super_Unit='kgs'
Member 12385326
22-Mar-16 3:47am
View
this is my insert update procedure for another table.but i have same problem with all my table.insert is working fine. but update is not working properly. i want to update all the column using unit_id.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[spr_unitCreation]
--Unit_Id int,
@Unit_Name varchar(50)=null,
@Unit_Abbreviation varchar(50)=null,
@Unit_type varchar(50)=null,
@Decimal_Places varchar(50)=null,
@Description varchar(50)=null,
@Super_Unit varchar(50)=null,
@Per_Unit varchar(50)=null,
@abc varchar(50)=null
As
begin
if @abc='insert' and @Unit_Type='Single'
begin
set nocount on;
DECLARE @Unit_Id int
insert into tbl_UnitCreation (Unit_Name,Unit_Abbreviation,Unit_type,
Decimal_Places,Description,Super_Unit,Per_Unit )values (@Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,@Super_Unit,@Per_Unit )
set @unit_Id=scope_identity();
end
if @abc='insert' and @Unit_Type='Compound'
insert into tbl_UnitCreation select @Unit_Name,@Unit_Abbreviation,@Unit_type,@Decimal_Places,@Description,[Unit_Name],@Per_Unit
from tbl_UnitCreation where Unit_Name=@Super_Unit and Unit_Type='Single'
set @unit_Id=scope_identity();
if @abc='update'
begin
set nocount on;
--declare @Unit_Id int
SELECT SCOPE_IDENTITY() AS unit_Id
update tbl_UnitCreation set Unit_Name=@Unit_Name,Unit_Abbreviation=@Unit_Abbreviation,
Unit_type=@Unit_type,
Decimal_Places=@Decimal_Places,Description=@Description,Super_Unit=@Super_Unit,Per_Unit=@Per_Unit
where unit_Id=unit_Id
end
end
select * from tbl_UnitCreation
--delete from tbl_UnitCreation where Super_Unit='kgs'
Member 12385326
18-Mar-16 7:26am
View
i got the solution by setting flag variable.
this is my insert and update procedure for my accountgroup table
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[spr_AccountGroup]
@Group_Name varchar(50)=null,
@Chbox_Val varchar(50)=null,
@UnderGroup varchar(50)=null,
@Comments varchar(50)=null,
@flag varchar(50)=null,
@abc varchar(50)=null
AS
BEGIN
IF @abc='insert'
BEGIN
--SET IDENTITY_INSERT tbl_AccountGroup ON
set nocount on;
DECLARE @Group_id int
if( ((@Group_name='Capital Account'or @Group_name='Loan' or @Group_name='Current Liabilities' or @Group_Name='Current Assets')and (@UnderGroup='Capital Account'or @UnderGroup='Loan' or @UnderGroup='Current Liabilities' or @underGroup='Current Assets'))or (@Group_name='Capital Account'or @Group_name='Loan' or @Group_name='Current Liabilities' or @Group_Name='Current Assets' ))
begin
insert into tbl_AccountGroup(Group_Name,Chbox_Val ,UnderGroup,Comments,flag)
values(@Group_Name,@Chbox_Val ,@UnderGroup,@Comments,'1')
select @Group_Name
set @Group_id= SCOPE_IDENTITY();
end
else
insert into tbl_AccountGroup(Group_Name,Chbox_Val ,UnderGroup,Comments,flag)
values(@Group_Name,@Chbox_Val ,@UnderGroup,@Comments,'0')
select @Group_Name
set @Group_id= SCOPE_IDENTITY();
end
if @abc='update'
begin
begin
update tbl_AccountGroup set Chbox_Val=@Chbox_Val ,UnderGroup=@UnderGroup,Comments=@Comments
where Group_Name=@Group_Name and flag='0'
end
end
END
Member 12385326
18-Mar-16 2:25am
View
i want to update my user defined record only not system record. but if i use above query then it is updatating every record which are not in where condition.
Member 12385326
18-Mar-16 2:25am
View
Deleted
i want to update my user defined record only not system record. but if i use above query then it is updatating every record which are not in where condition.
Member 12385326
17-Mar-16 7:24am
View
but it is updating each record not specific record.enen if i changed where clause according to my need.
Member 12385326
17-Mar-16 2:29am
View
UPDATE table1
SET field1 = @field1
WHERE group_name NOT IN('one', 'two', 'three') this query is updating all records which are not in where clause with same value.
Member 12385326
16-Mar-16 6:18am
View
ok.
Member 12385326
15-Mar-16 1:34am
View
thanks for your help
Member 12385326
15-Mar-16 1:32am
View
now i have one checkbox if that checkbox is checked then data should insert in first table if not checked then data should insert in second table.but i m confused in which table checkbox should be included and how to write procedure for that
Member 12385326
15-Mar-16 1:03am
View
thnks alot..my problem is solved of fetching data from one table to another one through procedure
by this query insert into subgroup select [grp_id],[Group_name],@SubGroup_Name,@Group_Nature from tbl_AccountGroup WHERE Group_name = @Group_name
Member 12385326
14-Mar-16 7:23am
View
Group_name is the column in parent table which i want to fetch into child table.how to write procedure for that.
Member 12385326
12-Mar-16 9:21am
View
I have dropdown list for child table. But I don't know how to write stored procedure for this in backend.(sql server) . I want procedure for two table which are in relation. How to fetch data from parent table and insert it in child table. I want to fetch only one column of parent table ;not all columns. Please help me out.i am new to sql.
Member 12385326
12-Mar-16 9:13am
View
I am still not getting it.can you please explain stored procedure to me with simple example of two table with primary key and foreign key.and Ho to insert data into first table and how to insert data in second table as well as how to fetch data from first table to second table which contains foreign key and insert into second table
Show More