Hand Needed With T-sql

Jul 20, 2005

Is it possible to write these two blocks of code as one? The only
difference between them is the AND clause: AND is_trade_date = 1 versus AND
is_sett_date = 1.

Cheers,

David

IF (@trade_dates = 1)
BEGIN
IF EXISTS (SELECT 1 FROM calendar
WHERE calendar_date = @date
AND is_trade_date = 1)
BEGIN
SELECT @day_cnt = @day_cnt + 1
END
END
ELSE
BEGIN
IF EXISTS (SELECT 1 FROM calendar
WHERE calendar_date = @date
AND is_sett_date = 1)
BEGIN
SELECT @day_cnt = @day_cnt + 1
END
END
END

View 3 Replies


ADVERTISEMENT

Need A Hand...

May 30, 2007

i've been writing an app for my company that has a front end screen in which the user types in all infos needed (ie. name, address, city, state, etc - 82 fields to be exact) then clicks an "add" button, which i put at the bottom, and have that data dumped into a SQL table... the page is then redirected to another page which reads the record just added and displays all the fields that the user submitted...
 here is my front end "add" screen code behind written in C#:
 
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Vinny_Credit_Application_AddCredApp : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{
}protected void SubmitButton_Click(object sender, EventArgs e)
{string ConnectionString = ConfigurationManager.ConnectionStrings["ws2dbConnectionString2"].ConnectionString;
SqlConnection connection = new SqlConnection(ConnectionString);SqlCommand cmd = new SqlCommand(@"INSERT INTO CreditAppFile (
GI_RB_Div,
GI_RB_ExistCust,
GI_TB_LegalFirmName,
GI_TB_Address,
GI_TB_City,
GI_DDL_State,
GI_TB_Zip,
GI_TB_TradeName,
GI_TB_BillAddress,
GI_TB_BillCity,
GI_DDL_BillState,
GI_TB_BillZip,
GI_TB_ContName,
GI_TB_Title,
GI_TB_MobilePager,
GI_TB_Email,
GI_TB_Fax,
GI_TB_BusDesc,
GI_TB_BusStartDate,
GI_TB_BusPhone,
GI_RB_PuchOrdsReq,
GI_RB_BusType,
GI_RB_LiensJudges,
GI_RB_TaxExempt,
GI_TB_FedIDNO,
GI_RB_PriorBankrupt,
GI_TB_PriorBankr,
BFR_TB_ContPhone,
BFR_TB_AcctNum1,
BFR_TB_AcctNum2,
BFR_TB_CurrBal1,
BFR_TB_CurrBal2,
BFR_TB_CurrBal3,
BFR_TB_CurrBal4,
BFR_RB_AcctType,
TR_TB_ContName1,
TR_TB_ContAddr1,
TR_TB_ContCity1,
TR_DDL_ContSt1,
TR_TB_ContZip1,
TR_TB_ContPhone1,
TR_TB_Cont_Acct1,
TR_TB_ContName2,
TR_TB_ContAddr2,
TR_TB_ContCity2,
TR_DDL_ContSt2,
TR_TB_ContZip2,
TR_TB_ContPhone2,
TR_TB_Cont_Acct2,
TR_TB_ContName3,
TR_TB_ContAddr3,
TR_TB_ContCity3,
TR_DDL_ContSt3,
TR_TB_ContZip3,
TR_TB_ContPhone3,
TR_TB_Cont_Acct3,
PI_TB_Name1,
PI_TB_HomeAddr1,
PI_TB_BDay1,
PI_TB_SSNum1,
PI_TB_HomePh1,
PI_TB_PrcntOwn1,
PI_TB_NetWorth1,
PI_TB_AnnInc1,
PI_TB_MonHouPay1,
PI_TB_Name2,
PI_TB_HomeAddr2,
PI_TB_BDay2,
PI_TB_SSNum2,
PI_TB_HomePh2,
PI_TB_PrcntOwn2,
PI_TB_NetWorth2,
PI_TB_AnnInc2,
PI_TB_MonHouPay2,
PI_TB_Name3,
PI_TB_HomeAddr3,
PI_TB_BDay3,
PI_TB_SSNum3,
PI_TB_HomePh3,
PI_TB_PrcntOwn3,
PI_TB_NetWorth3,
PI_TB_AnnInc3,
PI_TB_MonHouPay3
)
VALUES (
@GI_RB_Div,
@GI_RB_ExistCust,
@GI_TB_LegalFirmName,
@GI_TB_Address,
@GI_TB_City,
@GI_DDL_State,
@GI_TB_Zip,
@GI_TB_TradeName,
@GI_TB_BillAddress,
@GI_TB_BillCity,
@GI_DDL_BillState,
@GI_TB_BillZip,
@GI_TB_ContName,
@GI_TB_Title,
@GI_TB_MobilePager,
@GI_TB_Email,
@GI_TB_Fax,
@GI_TB_BusDesc,
@GI_TB_BusStartDate,
@GI_TB_BusPhone,
@GI_RB_PuchOrdsReq,
@GI_RB_BusType,
@GI_RB_LiensJudges,
@GI_RB_TaxExempt,
@GI_TB_FedIDNO,
@GI_RB_PriorBankrupt,
@GI_TB_PriorBankr,
@BFR_TB_ContPhone,
@BFR_TB_AcctNum1,
@BFR_TB_AcctNum2,
@BFR_TB_CurrBal1,
@BFR_TB_CurrBal2,
@BFR_TB_CurrBal3,
@BFR_TB_CurrBal4,
@BFR_RB_AcctType,
@TR_TB_ContName1,
@TR_TB_ContAddr1,
@TR_TB_ContCity1,
@TR_DDL_ContSt1,
@TR_TB_ContZip1,
@TR_TB_ContPhone1,
@TR_TB_Cont_Acct1,
@TR_TB_ContName2,
@TR_TB_ContAddr2,
@TR_TB_ContCity2,
@TR_DDL_ContSt2,
@TR_TB_ContZip2,
@TR_TB_ContPhone2,
@TR_TB_Cont_Acct2,
@TR_TB_ContName3,
@TR_TB_ContAddr3,
@TR_TB_ContCity3,
@TR_DDL_ContSt3,
@TR_TB_ContZip3,
@TR_TB_ContPhone3,
@TR_TB_Cont_Acct3,
@PI_TB_Name1,
@PI_TB_HomeAddr1,
@PI_TB_BDay1,
@PI_TB_SSNum1,
@PI_TB_HomePh1,
@PI_TB_PrcntOwn1,
@PI_TB_NetWorth1,
@PI_TB_AnnInc1,
@PI_TB_MonHouPay1,
@PI_TB_Name2,
@PI_TB_HomeAddr2,
@PI_TB_BDay2,
@PI_TB_SSNum2,
@PI_TB_HomePh2,
@PI_TB_PrcntOwn2,
@PI_TB_NetWorth2,
@PI_TB_AnnInc2,
@PI_TB_MonHouPay2,
@PI_TB_Name3,
@PI_TB_HomeAddr3,
@PI_TB_BDay3,
@PI_TB_SSNum3,
@PI_TB_HomePh3,
@PI_TB_PrcntOwn3,
@PI_TB_NetWorth3,
@PI_TB_AnnInc3,
@PI_TB_MonHouPay3
); Select Scope_Identity()"
, connection);
try
{cmd.Parameters.AddWithValue("@GI_RB_Div", GI_RB_Div.SelectedValue);
cmd.Parameters.AddWithValue("@GI_RB_ExistCust", GI_RB_ExistCust.SelectedValue);cmd.Parameters.AddWithValue("@GI_TB_LegalFirmName", GI_TB_LegalFirmName.Text);
cmd.Parameters.AddWithValue("@GI_TB_Address", GI_TB_Address.Text);cmd.Parameters.AddWithValue("@GI_TB_City", GI_TB_City.Text);
cmd.Parameters.AddWithValue("@GI_DDL_State", GI_DDL_State.SelectedValue);cmd.Parameters.AddWithValue("@GI_TB_Zip", GI_TB_Zip.Text);
cmd.Parameters.AddWithValue("@GI_TB_TradeName", GI_TB_TradeName.Text);cmd.Parameters.AddWithValue("@GI_TB_BillAddress", GI_TB_BillAddress.Text);
cmd.Parameters.AddWithValue("@GI_TB_BillCity", GI_TB_BillCity.Text);cmd.Parameters.AddWithValue("@GI_DDL_BillState", GI_DDL_BillState.SelectedValue);
cmd.Parameters.AddWithValue("@GI_TB_BillZip", GI_TB_BillZip.Text);cmd.Parameters.AddWithValue("@GI_TB_ContName", GI_TB_ContName.Text);
cmd.Parameters.AddWithValue("@GI_TB_Title", GI_TB_Title.Text);cmd.Parameters.AddWithValue("@GI_TB_MobilePager", GI_TB_MobilePager.Text);
cmd.Parameters.AddWithValue("@GI_TB_Email", GI_TB_Email.Text);cmd.Parameters.AddWithValue("@GI_TB_Fax", GI_TB_Fax.Text);
cmd.Parameters.AddWithValue("@GI_TB_BusDesc", GI_TB_BusDesc.Text);cmd.Parameters.AddWithValue("@GI_TB_BusStartDate", GI_TB_BusStartDate.Text);
cmd.Parameters.AddWithValue("@GI_TB_BusPhone", GI_TB_BusPhone.Text);cmd.Parameters.AddWithValue("@GI_RB_PuchOrdsReq", GI_RB_PuchOrdsReq.SelectedValue);
cmd.Parameters.AddWithValue("@GI_RB_BusType", GI_RB_BusType.SelectedValue);cmd.Parameters.AddWithValue("@GI_RB_LiensJudges", GI_RB_LiensJudges.SelectedValue);
cmd.Parameters.AddWithValue("@GI_RB_TaxExempt", GI_RB_TaxExempt.SelectedValue);cmd.Parameters.AddWithValue("@GI_TB_FedIDNO", GI_TB_FedIDNO.Text);
cmd.Parameters.AddWithValue("@GI_RB_PriorBankrupt", GI_RB_PriorBankrupt.SelectedValue);cmd.Parameters.AddWithValue("@GI_TB_PriorBankr", GI_TB_PriorBankr.Text);
cmd.Parameters.AddWithValue("@BFR_TB_ContPhone", BFR_TB_ContPhone.Text);cmd.Parameters.AddWithValue("@BFR_TB_AcctNum1", BFR_TB_AcctNum1.Text);
cmd.Parameters.AddWithValue("@BFR_TB_AcctNum2", BFR_TB_AcctNum2.Text);cmd.Parameters.AddWithValue("@BFR_TB_CurrBal1", BFR_TB_CurrBal1.Text);
cmd.Parameters.AddWithValue("@BFR_TB_CurrBal2", BFR_TB_CurrBal2.Text);cmd.Parameters.AddWithValue("@BFR_TB_CurrBal3", BFR_TB_CurrBal3.Text);
cmd.Parameters.AddWithValue("@BFR_TB_CurrBal4", BFR_TB_CurrBal4.Text);cmd.Parameters.AddWithValue("@BFR_RB_AcctType", BFR_RB_AcctType.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContName1", TR_TB_ContName1.Text);cmd.Parameters.AddWithValue("@TR_TB_ContAddr1", TR_TB_ContAddr1.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContCity1", TR_TB_ContCity1.Text);cmd.Parameters.AddWithValue("@TR_DDL_ContSt1", TR_DDL_ContSt1.SelectedValue);
cmd.Parameters.AddWithValue("@TR_TB_ContZip1", TR_TB_ContZip1.Text);cmd.Parameters.AddWithValue("@TR_TB_ContPhone1", TR_TB_ContPhone1.Text);
cmd.Parameters.AddWithValue("@TR_TB_Cont_Acct1", TR_TB_Cont_Acct1.Text);cmd.Parameters.AddWithValue("@TR_TB_ContName2", TR_TB_ContName2.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContAddr2", TR_TB_ContAddr2.Text);cmd.Parameters.AddWithValue("@TR_TB_ContCity2", TR_TB_ContCity2.Text);
cmd.Parameters.AddWithValue("@TR_DDL_ContSt2", TR_DDL_ContSt2.SelectedValue);cmd.Parameters.AddWithValue("@TR_TB_ContZip2", TR_TB_ContZip2.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContPhone2", TR_TB_ContPhone2.Text);cmd.Parameters.AddWithValue("@TR_TB_Cont_Acct2", TR_TB_Cont_Acct2.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContName3", TR_TB_ContName3.Text);cmd.Parameters.AddWithValue("@TR_TB_ContAddr3", TR_TB_ContAddr3.Text);
cmd.Parameters.AddWithValue("@TR_TB_ContCity3", TR_TB_ContCity3.Text);cmd.Parameters.AddWithValue("@TR_DDL_ContSt3", TR_DDL_ContSt3.SelectedValue);
cmd.Parameters.AddWithValue("@TR_TB_ContZip3", TR_TB_ContZip3.Text);cmd.Parameters.AddWithValue("@TR_TB_ContPhone3", TR_TB_ContPhone3.Text);
cmd.Parameters.AddWithValue("@TR_TB_Cont_Acct3", TR_TB_Cont_Acct3.Text);cmd.Parameters.AddWithValue("@PI_TB_Name1", PI_TB_Name1.Text);
cmd.Parameters.AddWithValue("@PI_TB_HomeAddr1", PI_TB_HomeAddr1.Text);cmd.Parameters.AddWithValue("@PI_TB_BDay1", PI_TB_BDay1.Text);
cmd.Parameters.AddWithValue("@PI_TB_SSNum1", PI_TB_SSNum1.Text);cmd.Parameters.AddWithValue("@PI_TB_HomePh1", PI_TB_HomePh1.Text);
cmd.Parameters.AddWithValue("@PI_TB_PrcntOwn1", PI_TB_PrcntOwn1.Text);cmd.Parameters.AddWithValue("@PI_TB_NetWorth1", PI_TB_NetWorth1.Text);
cmd.Parameters.AddWithValue("@PI_TB_AnnInc1", PI_TB_AnnInc1.Text);cmd.Parameters.AddWithValue("@PI_TB_MonHouPay1", PI_TB_MonHouPay1.Text);
cmd.Parameters.AddWithValue("@PI_TB_Name2", PI_TB_Name2.Text);cmd.Parameters.AddWithValue("@PI_TB_HomeAddr2", PI_TB_HomeAddr2.Text);
cmd.Parameters.AddWithValue("@PI_TB_BDay2", PI_TB_BDay2.Text);cmd.Parameters.AddWithValue("@PI_TB_SSNum2", PI_TB_SSNum2.Text);
cmd.Parameters.AddWithValue("@PI_TB_HomePh2", PI_TB_HomePh2.Text);cmd.Parameters.AddWithValue("@PI_TB_PrcntOwn2", PI_TB_PrcntOwn2.Text);
cmd.Parameters.AddWithValue("@PI_TB_NetWorth2", PI_TB_NetWorth2.Text);cmd.Parameters.AddWithValue("@PI_TB_AnnInc2", PI_TB_AnnInc2.Text);
cmd.Parameters.AddWithValue("@PI_TB_MonHouPay2", PI_TB_MonHouPay2.Text);cmd.Parameters.AddWithValue("@PI_TB_Name3", PI_TB_Name3.Text);
cmd.Parameters.AddWithValue("@PI_TB_HomeAddr3", PI_TB_HomeAddr3.Text);cmd.Parameters.AddWithValue("@PI_TB_BDay3", PI_TB_BDay3.Text);
cmd.Parameters.AddWithValue("@PI_TB_SSNum3", PI_TB_SSNum3.Text);cmd.Parameters.AddWithValue("@PI_TB_HomePh3", PI_TB_HomePh3.Text);
cmd.Parameters.AddWithValue("@PI_TB_PrcntOwn3", PI_TB_PrcntOwn3.Text);cmd.Parameters.AddWithValue("@PI_TB_NetWorth3", PI_TB_NetWorth3.Text);
cmd.Parameters.AddWithValue("@PI_TB_AnnInc3", PI_TB_AnnInc3.Text);cmd.Parameters.AddWithValue("@PI_TB_MonHouPay3", PI_TB_MonHouPay3.Text);
cmd.Connection = connection;
cmd.Connection.Open();string NewID = cmd.ExecuteScalar().ToString();
cmd.Connection.Close();
Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);
}catch (Exception ex)
{lblMessage.Text = "ERROR: " + ex.Message;lblMessage.Visible = true;
}
}
}
 
this seems to be ok... but i get a load of errors on my "read/display" page which looks like the folowing... (this is the code behind, again, written in C#)
 
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Vinny_Credit_Application_DisplayCredApp : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{if (!IsPostBack && Response["NewID"] != null)
{string ConnectionString = ConfigurationManager.ConnectionStrings["ws2dbConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(ConnectionString);SqlCommand cmd = new SqlCommand(@"SELECT * FROM CreditAppFile WHERE ID = @ID", connection);cmd.Parameters.Add("@ID", Response["NewID"].ToString());
connection.Open();SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
GI_RB_Div.Text = reader["GI_RB_Div"].ToString();GI_RB_ExistCust.Text = reader["GI_RB_ExistCust"].ToString();
GI_TB_LegalFirmName.Text = reader["GI_TB_LegalFirmName"].ToString();GI_TB_Address.Text = reader["GI_TB_Address"].ToString();
GI_TB_City.Text = reader["GI_TB_City"].ToString();GI_DDL_State.Text = reader["GI_DDL_State"].ToString();
GI_TB_Zip.Text = reader["GI_TB_Zip"].ToString();GI_TB_TradeName.Text = reader["GI_TB_TradeName"].ToString();
GI_TB_BillAddress.Text = reader["GI_TB_BillAddress"].ToString();GI_TB_BillCity.Text = reader["GI_TB_BillCity"].ToString();
GI_DDL_BillState.Text = reader["GI_DDL_BillState"].ToString();GI_TB_BillZip.Text = reader["GI_TB_BillZip"].ToString();
GI_TB_ContName.Text = reader["GI_TB_ContName"].ToString();GI_TB_Title.Text = reader["GI_TB_Title"].ToString();
GI_TB_MobilePager.Text = reader["GI_TB_MobilePager"].ToString();GI_TB_Email.Text = reader["GI_TB_Email"].ToString();
GI_TB_Fax.Text = reader["GI_TB_Fax"].ToString();GI_TB_BusDesc.Text = reader["GI_TB_BusDesc"].ToString();
GI_TB_BusStartDate.Text = reader["GI_TB_BusStartDate"].ToString();GI_TB_BusPhone.Text = reader["GI_TB_BusPhone"].ToString();
GI_RB_PuchOrdsReq.Text = reader["GI_RB_PuchOrdsReq"].ToString();GI_RB_BusType.Text = reader["GI_RB_BusType"].ToString();
GI_RB_LiensJudges.Text = reader["GI_RB_LiensJudges"].ToString();GI_RB_TaxExempt.Text = reader["GI_RB_TaxExempt"].ToString();
GI_TB_FedIDNO.Text = reader["GI_TB_FedIDNO"].ToString();GI_RB_PriorBankrupt.Text = reader["GI_RB_PriorBankrupt"].ToString();
GI_TB_PriorBankr.Text = reader["GI_TB_PriorBankr"].ToString();BFR_TB_ContPhone.Text = reader["BFR_TB_ContPhone"].ToString();
BFR_TB_AcctNum1.Text = reader["BFR_TB_AcctNum1"].ToString();BFR_TB_AcctNum2.Text = reader["BFR_TB_AcctNum2"].ToString();
BFR_TB_CurrBal1.Text = reader["BFR_TB_CurrBal1"].ToString();BFR_TB_CurrBal2.Text = reader["BFR_TB_CurrBal2"].ToString();
BFR_TB_CurrBal3.Text = reader["BFR_TB_CurrBal3"].ToString();BFR_TB_CurrBal4.Text = reader["BFR_TB_CurrBal4"].ToString();
BFR_RB_AcctType.Text = reader["BFR_RB_AcctType"].ToString();TR_TB_ContName1.Text = reader["TR_TB_ContName1"].ToString();
TR_TB_ContAddr1.Text = reader["TR_TB_ContAddr1"].ToString();TR_TB_ContCity1.Text = reader["TR_TB_ContCity1"].ToString();
TR_DDL_ContSt1.Text = reader["TR_DDL_ContSt1"].ToString();TR_TB_ContZip1.Text = reader["TR_TB_ContZip1"].ToString();
TR_TB_ContPhone1.Text = reader["TR_TB_ContPhone1"].ToString();TR_TB_Cont_Acct1.Text = reader["TR_TB_Cont_Acct1"].ToString();
TR_TB_ContName2.Text = reader["TR_TB_ContName2"].ToString();TR_TB_ContAddr2.Text = reader["TR_TB_ContAddr2"].ToString();
TR_TB_ContCity2.Text = reader["TR_TB_ContCity2"].ToString();TR_DDL_ContSt2.Text = reader["TR_DDL_ContSt2"].ToString();
TR_TB_ContZip2.Text = reader["TR_TB_ContZip2"].ToString();TR_TB_ContPhone2.Text = reader["TR_TB_ContPhone2"].ToString();
TR_TB_Cont_Acct2.Text = reader["TR_TB_Cont_Acct2"].ToString();TR_TB_ContName3.Text = reader["TR_TB_ContName3"].ToString();
TR_TB_ContAddr3.Text = reader["TR_TB_ContAddr3"].ToString();TR_TB_ContCity3.Text = reader["TR_TB_ContCity3"].ToString();
TR_DDL_ContSt3.Text = reader["TR_DDL_ContSt3"].ToString();TR_TB_ContZip3.Text = reader["TR_TB_ContZip3"].ToString();
TR_TB_ContPhone3.Text = reader["TR_TB_ContPhone3"].ToString();TR_TB_Cont_Acct3.Text = reader["TR_TB_Cont_Acct3"].ToString();
PI_TB_Name1.Text = reader["PI_TB_Name1"].ToString();PI_TB_HomeAddr1.Text = reader["PI_TB_HomeAddr1"].ToString();
PI_TB_BDay1.Text = reader["PI_TB_BDay1"].ToString();PI_TB_SSNum1.Text = reader["PI_TB_SSNum1"].ToString();
PI_TB_HomePh1.Text = reader["PI_TB_HomePh1"].ToString();PI_TB_PrcntOwn1.Text = reader["PI_TB_PrcntOwn1"].ToString();
PI_TB_NetWorth1.Text = reader["PI_TB_NetWorth1"].ToString();PI_TB_AnnInc1.Text = reader["PI_TB_AnnInc1"].ToString();
PI_TB_MonHouPay1.Text = reader["PI_TB_MonHouPay1"].ToString();PI_TB_Name2.Text = reader["PI_TB_Name2"].ToString();
PI_TB_HomeAddr2.Text = reader["PI_TB_HomeAddr2"].ToString();PI_TB_BDay2.Text = reader["PI_TB_BDay2"].ToString();
PI_TB_SSNum2.Text = reader["PI_TB_SSNum2"].ToString();PI_TB_HomePh2.Text = reader["PI_TB_HomePh2"].ToString();
PI_TB_PrcntOwn2.Text = reader["PI_TB_PrcntOwn2"].ToString();PI_TB_NetWorth2.Text = reader["PI_TB_NetWorth2"].ToString();
PI_TB_AnnInc2.Text = reader["PI_TB_AnnInc2"].ToString();PI_TB_Name2.Text = reader["PI_TB_MonHouPay2"].ToString();
PI_TB_Name3.Text = reader["PI_TB_Name3"].ToString();PI_TB_HomeAddr3.Text = reader["PI_TB_HomeAddr3"].ToString();
PI_TB_BDay3.Text = reader["PI_TB_BDay3"].ToString();PI_TB_SSNum3.Text = reader["PI_TB_SSNum3"].ToString();
PI_TB_HomePh3.Text = reader["PI_TB_HomePh3"].ToString();PI_TB_PrcntOwn3.Text = reader["PI_TB_PrcntOwn3"].ToString();
PI_TB_NetWorth3.Text = reader["PI_TB_NetWorth3"].ToString();PI_TB_AnnInc3.Text = reader["PI_TB_AnnInc3"].ToString();PI_TB_MonHouPay3.Text = reader["PI_TB_MonHouPay3"].ToString();
connection.Close();
}
}
}
 
been working on this for days... everytime i get a little closer i seem to get that much farther away... if you can help by all means give me what you got...
thanks for all the help in advance!!!!
 
- Vinny

View 7 Replies View Related

Hey.. Two Issues At Hand.

May 15, 2008

Hello !

I came across some interesting issues that solving them will definately help me a lot !

1) Is there a way to insert my database a row, and that it will automatically fill up the datetime column with the local machine time ? (so that I won't have to worry about users local time)

2) I'm trying to synchronize between two data sources - one is my DB and the other is a file. The data in the file should represent the data to be in the DB. However, I don't want to delete all the records and then just insert everything in the file, but to perform Insert, Update or Delete operations according to the file's changes. I managed to do the Insert and Update, but I can't find a solution to a scenario where old data, which is on the DB but not on the file, could be deleted from the DB.

I appreciate the help A LOT !

View 3 Replies View Related

Need Hand Holding

Oct 7, 2007

Hi -
Is there a resource I can go to that lists people who I pay to talk me through stuff like getting SQL Server Express installed, get some sample data input and then get that data into Excel? I just cannot seem to get any help that works for me to learn SQL Server; the books are obtuse, the online help too indirect. Once I get something working I hope to enhance it on my own, but I have been stuck at the start for a very long time. There is stuff for me to do that is not getting done.

Doug

View 1 Replies View Related

Lend A Hand With A Query

Aug 23, 2007

I have a question about a query.I have 2 tables:As an example I have the following tables (not my real tables)1) lstParts: Complete list of parts with 2 fields:  partID, partName.2) tblOrders: table of orders with 2 fields:  partID, custIDObviously the partID’s are keys to each other.
What I want is a list of all the records in lstParts that are not in tblOrders for an individual customer.  So it might answer, “what parts has this customer NOT ordered?â€?
What I have so far is close but it is repeating the correct result for each row in tblOrders. 
Here is what I have so far
 SELECT
p.partID,
p.partName
FROM
lstParts p
LEFT OUTER JOIN tblOrders o
ON p.partID <> o.partID
WHERE
o.custID = ‘123’ 
Any help would be appreciated-Thanks

View 2 Replies View Related

Right Hand Side Of Report Is Cut Off

Mar 28, 2006

I have a table control on a report that is when it is displayed it shows the right side of the report being cut off. If I go to the next page the report displays properly. When I go back to the first page it then displays properly.

How can I get it to display properly the first time it is viewed?

View 2 Replies View Related

Right-hand Side Of Report Being Cut Off

Jan 18, 2006

 
Folks,
 
On matrix reports, when viewed with IE through the ReportServer URL access page, Matrix reports are getting cut off on the right-hand side to the original size of the report.  However, this corrects itself immediately if you toggle any item, or change the zoom level.
 
What's really confusing is that most of our reports that have expanding functionality work just fine -- there's just a couple that don't.  We have spent a couple days trying to figure out what's different with no luck.
 
EDITED: navigating away from the page by typing another URL in the address bar, and then hitting back, corrects this.  The problem is also not present with &rc:Toolbar=false, but with the toolbar on, it's there.
 
Any ideas?
 
Thanks so much!
--randy
 

View 1 Replies View Related

HAND SYMBOL ON DATABASE BARREL

Oct 27, 1999

We are running SQL Version 7.0.
I recently set up a simple snapshot replication. After restarting enterprise manager a hand symbol showed up under the database barrel as if a share symbol.
Am I correct in assuming the symbol means replication. Is there a source that explains what the various symbols mean?

View 1 Replies View Related

Prelogin Shake Hand Error

Jan 16, 2008

Dear All,
i'm getting this error while trying to connect to any of the servers.
on that perticular system, sqlserver2000, 2005 client tools are there.

the error is :
a connection was established successfully to the server but an error was occured prelogin handshake. how can i overcome this?


thank you very much

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 1 Replies View Related

Newbie Needs A Hand With SQL2005 Reports

May 24, 2007

I'm trying to run some reports on SQL 2005, but can't even pass the first step of launching the report builder. I have SQL2005 on my local machine, but the report server is installed on a remote server. I launched SQL Business Intelligence Development Studio, which brings Visual studio, but i keep getting a prompt to enter a connection string. How do i get the connection string, or how do i set up my datasource?



Help!

View 1 Replies View Related

Need A Quick Hand Using ORDER BY With Two Fields In The Same Table.

Aug 6, 2004

I have a problem with ordering and I am hoping that someone is able to help.

In my table I have two fields, "requestdate" and "sentdate", and when I display the records I would like to sort by BOTH fields. I want to do this so that the full query is in order by date.

I tried:

ORDER BY requestdate, sentdate DESC

But obviously all that does is order by requestdate (which is NULL or a date) and than it will order by sentdate.

Can somebody tell me how to order by both as if they were the same field?

Thanks!

View 2 Replies View Related

Vs2005 Helpï¼?ï¼?ï¼?ï¼? Give Me A Hand ! Waiting On Line

Feb 24, 2006

vs2005  helpï¼?ï¼?ï¼?ï¼? a textbox ,a button , a sqldatasource ,a dataview    when click the button  execute sql:  select * from authors where name=''+textbox.text+''
the dataset returned list in  dataview , just like c/s  。 I feel it very hard to
contral sqldatasource,
code is holpful 2!

View 1 Replies View Related

SQL Server Equivalent For DATE LIKE '%__/Apr/2006%' (was Please Give Me A Hand...)

Apr 10, 2006

I'm happyguy and this is the first time to post my problem. Thanks a lot

here is a SQL query that I know how to write in Oracle, which is

Select * from AttandanceRecord where date like '%__/Apr/2006%'

but, now i'm developing my system with using Ms Sql Server 2000, so I don't know how to write a query with same output as above...

Please, can somebody help me??

View 6 Replies View Related

Sqldatasource Setting Reset After Page Postback, Could Anyone Give Me A Hand On This

Nov 25, 2005

Hi, I have created a search page which needs to perform different
search function in same page. I have setuped a sqldatasource then
manual
setup the connection string and command inside the codefile. So the
select command can be various depends on the event. The problem is
all of those setting will be reset after I click on the pageindex in
the girdview control to go to next pages. Since this gridview is linked

with this sqldatasource control, I need to restore the connection
string/command when user choose decide to view next page of data inisde
the
gridview.

I think I must have done something wrong in here becuase it will end up
retrieving  the total amount of data when everytime user choose to
view next
or perivous page.

Can someone give me a hand on this ? Thanks

View 1 Replies View Related

SQL 2012 :: Calculate Stock Aging Based On Hand Quantity

Jan 18, 2015

I want to calculate stock aging (qty, cost) based on the on hand quantity.

Currently I am recording only in/out transaction only.

For ex: Item A i have 115 pieces (Balance stock) as on to day.

Transaction History
---------------------
Lot 1 - 01/01/2015 - 50
Lot 2 - 10/02/2015 - 50
Lot 3 - 11/03/2015 - 50
Lot 4 - 15/04/2014 - 50

I want to calculate cost of balance qty as shown below.

Jan -
Feb - 15 @ 1.1
Mar - 50 @ 0.90
Apr - 50 @ 1.2

Database schema
--------------------
CREATE TABLE [dbo].[StockManagement](
[Uniid] [int] IDENTITY(1,1) NOT NULL,
[StockCode] [int] NULL,
[TransactionDate] [datetime] NULL,
[TransactionTime] [time](0) NULL,

[Code] .....

View 0 Replies View Related

Possible To Stop SSRS GUI From Destroying Hand Rolled Mdx In Datasets By Silently Reverting To Design Mode?

May 30, 2007

Since as soon as you extend your mdx datasets manually you can no longer switch back into design mode without losing your changes, right?

If that's the case, is there some way to disable design mode completely? i'm finding that the GUI has the tendency to SILENTLY revert the dataset editor back to design mode while I'm busy editing a layout, thereby losing my carefully crafted MDX.

View 4 Replies View Related

SSRS Date Parameter - Showing Date Format On Right Hand Side

Jul 24, 2007

I am having report parameter end date I am showing the default value "5/21/2007 11:59:59 PM" in the end date paramter. And also I want to show date time format "(MM/DD/YYYY HH:MMS)" in the right hand side of the parameter. How to do this?



Thank You

View 1 Replies View Related

Sp Help Needed

Sep 24, 2006

Im new to stored procedure, but here's what I want, if someone can get me started and provide this as an example it would be VERY welcome!I have the following, a SP with parameter IsMale. This parameter may be empty. If it's not empty I want to add some text to my selection query: AND IsMale=paramvalueHere's the SP so far:ALTER PROCEDURE [dbo].[spFindUsersAdvanced] --declare parameters here@IsMale bitASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON;   SELECT DISTINCT BirthDate,IsMale, FROM aspnet_Users INNER JOIN tblUserData ON aspnet_Users.UserId = tblUserData.UserID WHERE tblUserData.Username<>''IF @IsMale THENBEGIN  AND IsMale='True'ENDELSEBEGIN  AND IsMale='False'ENDEND IFEND1. How do I check if the parameter is empty?2. How do I add the text to my selection query?

View 3 Replies View Related

Help Needed

Oct 30, 2007

Hi all,I am trying to write a stored procedure, which has two insert statements.the first insert statement, is simple which inserts data into a table and returns the primary key for the new row added. using this primary key, i am writing another insert statement, which passes a list of elements which would be then entered into another table, with the primary key of the first table.Is this possible to do in a single stored procedure? I have implemented this using two different sp, but am wondering if it can be done other way?thanks for your help! 

View 10 Replies View Related

Help Needed

Dec 1, 2004

Hi,

For many to many relationship, what is the minimum number of tables required.

View 1 Replies View Related

Hep Needed!!!

Oct 17, 2005

Hi plz read below is my scenarioI have two diff tables which stores passwords (don't ask why b'coz it was there).Now to make data in both table consistance what I need to do?plz provide optimized solution.Thanks in advance.bye bye.happy coding!!!

View 1 Replies View Related

Help Needed.

Dec 20, 2000

Experts,

I've few questions regarding SQL Server. Appreciated, If any one out there help me with it.

I would like to do T-SQL Programing and would like to know some good book. I'll mostly be doing Stored procedures,Triggers and views programming. Any advice?

On my sql server I've 10 logins. But, I cannot view these logins from the Enterprise GUI. But, When i run a query against the syslogin table, those all 10 logins shows up. Why is that?

any help would be greatly appreciated.

View 1 Replies View Related

SQL Help Needed.......

Mar 25, 2004

Access 97.................

I'm trying to construct the following SQL statement but am missing something somewhere.

I get a syntax error with the 1st FROM highlighted.

If i construct a query out of the bit that works and then construct a query on that query then i can get it to work no problem but how to mimic that in SQL ? I can't simply view the SQL of the queries because the query names replace the SQL statements.

I'm trying to SUM the 5 volumes that get returned by the TOP 5 SQL statement. The VotingUniverse_TotalVolumeByType query returns the TotalVolume which will enable me to divide the SUMmed 5 volumes by the TotalVolume to obtain a %age.



SELECT
Type,
Sum(Volume) AS Volume,
TotalVolume
FROM
>>>>>>>>>>this following bit works............
(SELECT TOP 5
VotingUniverse_TopFirmsVolumeByType.Type,
VotingUniverse_TopFirmsVolumeByType.Volume
FROM
VotingUniverse_TopFirmsVolumeByType
WHERE
(((VotingUniverse_TopFirmsVolumeByType.Volume)
In (SELECT TOP 5 VotingUniverse_TopFirmsVolumeByType.Volume
FROM
VotingUniverse_TopFirmsVolumeByType
ORDER BY Volume DESC)))
ORDER BY
VotingUniverse_TopFirmsVolumeByType.Volume;)
>>>>>>>>>>>end of bit that works
INNER JOIN
VotingUniverse_TotalVolumeByType
ON
Type = VotingUniverse_TotalVolumeByType.Type
GROUP BY
Type,
TotalVolume;



hope this makes sense to someone anyway

thanks


====
Paul

View 5 Replies View Related

Immediate Help Needed!! Thanks A Lot!

Aug 15, 2002

I have a xxx.exe running on SQL 2000 server as a sql job every hour. For some reason this job sometime just hung in the middle and never finish. But
if I stop it and rerun it, it will be down within 10 seconds. I am wondering
if we can set up something so that the job aborts automatically if it ran more than 10 minutes.

View 1 Replies View Related

Help Needed!!!

Feb 22, 2001

Hi everyone.

We are running Sql 6.5 sp5 on a Pentium II 350 Mhz with 512 Mb. RAM, 1 ScSi 4 Gb hd, one 8Gb ScSi hd and 2 IDE hd (13,6 Gb and 8Gb) computer running windows NT 4.0 sp 6 without any problems.
Now have bought a new computer. The new one is a Pentium III 733 Mhz 512 Mb Ram with 2 ScSi ultra wide 2 18Gb each and one 40 Gb Ide Hd. We have installed windows NT 4.0 sp 6 and Sql 6.5 sp 5. We have restored our database to make some tests to it. The database is 7 Gb big.
The results of our test are that the old computer is between 20% and 30% faster than the new one when doing sql instructions and using the database even knowing that the hd´s of the new computers are 4 times faster than the old ones.

Would you please give us any help or clue that would make the new computer go faster?
We know that upgrading to sql 7 will work but we need first to make this computer work better with the 6.5.
Thank you.

View 3 Replies View Related

Help Needed

Jun 18, 2004

Hello,
When I try to run my asp file it gives me this error. :mad:

Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
Syntax error converting datetime from character string.
/conOpen_inc.asp, line 10


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

Page:
GET /Default.asp


Anyone can tell me whats happening ? thank you

View 5 Replies View Related

DTS Help Needed!

Oct 12, 2004

I often use DTS to move databases between the servers. When you choose "Transform" data and “Column Mappings and Transformation” window opens, the default option is “Append rows to destination table”.
Question: Is there a way to change the default option to “Delete rows in destination table”, so I wouldn’t have to go thru the transformation of dozens of tables every time I move databases around.

P.S. I know that I can save DTS package with my settings and use it later. The problem is that every time it might be different database or objects might change. So, it is not a solution for me.

Thanks

View 8 Replies View Related

SQL DB Help Needed!!!

Jul 25, 2007

Dear All,

I have a client requirement. We are integrating two applications. So the problem is that, whenever some updates (meaning to say "create" , "delete" , "update") happens in the SQL DB Tables, i needed to track that data and send it to a different system.

What I have thought abt is that if SQL could generate a file with all the values deleted/updated/created in the DB, then I could take those values and do the needful. Please help me..

Thanks,
Sanjo

View 2 Replies View Related

Help Needed!!

Feb 28, 2004

Hello guys,
I'm new to the forum and to MS SQL 2K.
I'm trying to a merge similar rows in a table into a single row and put them in a new table.

Example:-
This is my input table
TableA
ID A B C
------------------------
1 jk kl bj
2 sd we op
3 io po kl
1 ui gh ew
2 kl re op
1 qw kj nn

My output table should look like this
TableB
ID A1 B1 C1 A2 B2 C2 A3 B3 C3
-----------------------------------------------------
1 jk kl bj ui gh ew qw kj nn
2 sd we op kl re op
3 io po kl

Please help me on how to create my output.
Thanks in advance,

Sid.

View 11 Replies View Related

Help NEeded!!

Mar 26, 2004

Hi,
I have a table structure like this

TableName: Common

Columns
PartnerId: int
NativeId: int
FirstName: nvarchar(50)
LastName:nvarchar(50)

1)I should get the records with a minimum native id for a particular PartnerId,
2) if duplicates exists in the above condition i should select top 1 (first record)


How can i do it??

TIA,
sudheer

View 5 Replies View Related

Help Needed!!

Apr 12, 2004

Hi,
I have been SQL developer for past 2 yrs, want to get into Administration(DBA) can any one suggest me some good articles on net and good books for this.

TIA,

sudheer.

View 14 Replies View Related

Is It Needed?

Feb 26, 2008

Hi experts,

I am upgrading my database from SQL Server 2000, SP4 to SQL server 2005, SP2.

1) Is it required to recreated my user defined functions? I mean drop them and recreate them again?

2) Do I need to recreate the views and Stored procedure?


3) Do we have a checklist from Micorosoft for upgradation?


Thanks in advance

Regards
Sachin

Don't sit back because of failure. It will come back to check if you still available. -- Binu

View 2 Replies View Related

Help Needed!!

Jul 23, 2005

Hey all, I need some help to build some data bases and maybe some morestuff. Please reply only if you can do it volunteerly or very cheap please;but there is incentives in time..TIA

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved