Problem Inserting Calculated Data Using Sqldatasource, PLEASE HELP....!!

Jun 26, 2006

Hi, I have created a website and I have a web form, I need to capture data and calculate fields and then insert the calculated field including the data into a sqlserver database. I created a store procedure and the parameters for the txt boxes is working fine. But the calculated fieldds are not getting inserted. Can someone please help? the code for insert is below: For the calculated field, I used txtboxes which "hold" the calculated field in the submit button event. I also tried using query string field

like this: but that did not work either. Help will be very much appreciated.

<asp:QueryStringParameter DefaultValue="1" Name="totlabchg" QueryStringField="laborcharge"

Type="Decimal" />__________________

<InsertParameters>

<asp:FormParameter DefaultValue="0" FormField="txtaccount" Name="ActNumber" Type="String" />

<asp:FormParameter DefaultValue="0" FormField="txtmeter" Name="MeterNumber" Type="String" />

<asp:FormParameter DefaultValue="0" FormField="txtdov" Name="VisitDate" Type="DateTime" />

<asp:FormParameter DefaultValue="" FormField="txtsvadd" Name="SvAdd" Type="String" />

<asp:Parameter Name="TampId2" Type="Int32" />

<asp:Parameter DefaultValue="64.44" Name="charge1" Type="Decimal" />

<asp:FormParameter FormField="txtq1" Name="quantity1" Type="Int32" />



<asp:QueryStringParameter DefaultValue="1" Name="subtotal1" QueryStringField="sub1" Type="Decimal" />

<asp:FormParameter DefaultValue="1" FormField="txtpeople" Name="labor" Type="Int32" />

<asp:FormParameter DefaultValue="1" FormField="txthrs" Name="laborhrs" Type="Decimal" />

<asp:FormParameter DefaultValue="1" FormField="txttotlab" Name="totlabchg" Type="Decimal" />

<asp:Parameter DefaultValue="300.00" Name="flatrate" Type="Decimal" />

<asp:FormParameter DefaultValue="1" FormField="txttotalcharge" Name="totalcharge"

Type="Decimal" />

<asp:FormParameter DefaultValue="1" FormField="txtgrandtotal" Name="grandtotal" Type="Decimal" />

<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />

</InsertParameters>

Thanks.

View 1 Replies


ADVERTISEMENT

Inserting Multiple Rows Into One Table (with Calculated Fields)

Nov 29, 2006

Hello all,my first post here...hope it goes well. I'm currently working onstored procedure where I translated some reporting language into T-SQLThe logic:I have a group of tables containing important values for calculation.I run various sum calculations on various fields in order to retrievecost calculations ...etc.1) There is a select statement which gathers all the "records" whichneed calculations.ex: select distinct Office from Offices where OfficeDesignation ='WE' or OfficeDesignation = 'BE...etc.As a result I get a list of lets say 5 offices which need to becalculated!2) A calculation select statement is then run on a loop for each ofthe returned 5 offices (@OfficeName cursor used here!) found above.Anexample can be like this(* note that @WriteOff is a variable storing the result):"select @WriteOff = sum(linecost * (-1))From Invtrans , InventoryWhere ( transtype in ('blah', 'blah' , 'blah' ) )and ( storeloc = @OfficeName )and ( Invtrans.linecost <= 0 )and ( Inventory.location = Invtrans.storeloc )and ( Inventory.itemnum = Invtrans.itemnum )"...etcThis sample statement returns a value and is passed to the variable@WriteOff (for each of the 5 offices mentioned in step 1). This is donearound 9 times for each loop! (9 calculations)3) At the end of each loop (or each office), we do an insert statementto a table in the database.


Quote:

View 9 Replies View Related

Need Help Inserting From SqlDataSource

Feb 18, 2008

If anyone can see what else I need to insert the stuff below into my database, I'd really appreciate it. I get intellisense, but also this error: Cannot insert the value NULL into column 'UserID' strUserName = cuwCreate.UserName.ToString
strUserID = Membership.GetUser(strUserName).ProviderUserKey.ToString()
Session("NewUserName") = strUserName
Session("NewUserID") = strUserID  <asp:SqlDataSource ID="srcCreateUser" runat="server" ConnectionString="<%$ ConnectionStrings:webConn %>"
InsertCommand="sp_CreateUser" InsertCommandType="StoredProcedure" SelectCommand="sp_CreateUser"
SelectCommandType="StoredProcedure" UpdateCommand="sp_CreateUser" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="NewUserID" Type="String" />
<asp:ControlParameter ControlID="UserName" DefaultValue="" Name="UserName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Email" Name="Email" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtFirstName" Name="FirstName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="txtLastName" Name="LastName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="txtTeacher" Name="Teacher" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtGradYr" Name="GradYr" PropertyName="Text" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:SessionParameter Name="UserID" SessionField="NewUserID" Type="String" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Teacher" Type="String" />
<asp:Parameter Name="GradYr" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>Dim obj As SqlDataSource = cuwRegister.ContentTemplateContainer.FindControl("srcCreateUser")
obj.Insert() 

View 17 Replies View Related

Sqldatasource Control Inserting Problems

Oct 6, 2006

I set up a Sqldatasource control in 2.0 and I can retrieve data through a SQL Server connection from a stored procedure.  My problem is when I set up the insert command object through the wizard for the Sqldatasource control with another stored procedure for inserting data and call the insert method of my Sqldatasource object i get nothing not even an error it just goes through the code like nothing was wrong and I don't get anything inserted.  I don't know if this could be a problem but one of the parameters in the stored procedure is declared like this: @return tinyint output. I don't know how the Sqldatasource accounts for return parameters.  Here is the code for the insert for the Sqldatasource object.<asp:SqlDataSource ID="sdsMain" runat="server" ConnectionString="<%$ ConnectionStrings:SN_CUSTOMERConnectionString %>"InsertCommand="uspSNOrder_Promo_Live" InsertCommandType="StoredProcedure" SelectCommand="uspOPFillPromo"SelectCommandType="StoredProcedure"><InsertParameters><asp:ControlParameter ControlID="ddlPromo" Name="promoid" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="1" Name="datasourceid" Type="Int32" /><asp:Parameter DefaultValue="0" Name="datasourcekey" Type="String" /><asp:Parameter DefaultValue="9" Name="salesroomid" Type="Int32" /><asp:Parameter DefaultValue="9999" Name="userid" Type="Int32" /><asp:ControlParameter ControlID="txtFName" DefaultValue="" Name="firstname" PropertyName="Text"Type="String" /><asp:ControlParameter ControlID="txtLName" Name="lastname" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtAddress" Name="address" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtCity" Name="city" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtState" Name="state" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtZip" Name="zip" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtPhone" Name="phone" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtEmail" Name="email" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="0" Direction="InputOutput" Name="return" Type="Byte" /></InsertParameters></asp:SqlDataSource>Thanks in advance

View 1 Replies View Related

SqlDataSource Inserting Event Error

Apr 12, 2007

Greetings,
When using Inserting event of SqlDataSource ASP.NET gives me an error when I reference InsertParameter by Name
An SqlParameter with ParameterName 'CreatedByEmployeeId' is not contained by this SqlParameterCollection.
However, when I reference parameter by index everything works.
Is this a bug or I'm doing something wrong?
Here's the code:
<asp:SqlDataSource ID="dsRole" runat="server" ConnectionString="<%$ ConnectionStrings:SecurityConnectionString %>" DeleteCommand="spDeleteRole" InsertCommand="spAddRole" SelectCommand="spGetRole" UpdateCommand="spUpdateRole" DeleteCommandType="StoredProcedure" InsertCommandType="StoredProcedure" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="RoleId" Type="Int32" />
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="UpdatedByEmployeeId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="RoleName" Type="String" />
<asp:Parameter Name="RoleDescription" Type="String" />
<asp:Parameter Name="CreatedByEmployeeId" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="RoleId" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
When using parameter name, I get an error:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters("CreatedByEmployeeId").Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub
When using index instead of name, there's no problem:
Protected Sub dsRole_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsRole.Inserting
e.Command.Parameters(2).Value = Internal.Security.GetEmployeeIdFromCookie(Page.Request.Cookies)
End Sub

View 2 Replies View Related

Inserting Variables Into A Query Using SqlDataSource

Jan 4, 2008

 Hi all,
I was wondering if anyone can help me figure out how to insert a
variable into a query using Visual Studio 2005 with the SqlDataSource
control. I cant seem to be able to enter a var into the query
parameters.

this is my SqlDataSource:
        <asp: SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:imLookinLikeConnectionString
%>"            DeleteCommand="DELETE FROM [tblDiaryEntries] WHERE [DiaryEntryID] = @DiaryEntryID"           
SelectCommand="SELECT tblDiaryEntries.DiaryEntryID,
tblDiaryEntries.EntryDate, tblDiaryEntries.Subject,
tblDiaryEntries.DiaryEntry, aspnet_Users.UserName FROM tblDiaryEntries
INNER JOIN aspnet_Users ON tblDiaryEntries.UserID = aspnet_Users.UserId
WHERE UserName=@UserName ORDER BY tblDiaryEntries.EntryDate DESC"           
UpdateCommand="UPDATE [tblDiaryEntries] SET [DiaryEntry] = @DiaryEntry,
[EntryDate] = @EntryDate, [Subject] = @Subject WHERE [DiaryEntryID] =
@DiaryEntryID" InsertCommand="INSERT INTO tblDiaryEntries(UserID,
EntryDate, Subject, DiaryEntry) VALUES (@UserId, GETDATE(), @Subject,
@DiaryEntry)">            <DeleteParameters>                <asp: Parameter Name="DiaryEntryID" Type="Int32" />            </DeleteParameters>            <UpdateParameters>                <asp: Parameter Name="DiaryEntry" Type="String" />                <asp: Parameter Name="EntryDate" Type="String" />                <asp: Parameter Name="Subject" Type="String" />                <asp: Parameter Name="DiaryEntryID" Type="Int32" />            </UpdateParameters>            <InsertParameters>                <asp: Parameter Name="DiaryEntry" Type="String" />                <asp: Parameter Name="EntryDate" Type="String" />                <asp: Parameter Name="Subject" Type="String" />                <asp: ProfileParameter DefaultValue="Anonymous" Name="UserName" PropertyName="UserName" />                <asp: Parameter Name="UserId" />            </InsertParameters>            <SelectParameters>                <asp: ProfileParameter DefaultValue="Anonymous" Name="UserName" PropertyName="UserName" />            </SelectParameters>        </asp: SqlDataSource>
What I want to do is to tell the SqlDataSource that  @UserName = this.User.Identity.Name, but I only know how to do that in
code-behind, not sure how to insert it into the code above.Any ideas?

View 3 Replies View Related

Inserting The Date As Defaultvalue In A Sqldatasource Parameter

Sep 21, 2006

Hi Guys. I am trying to insert the date as the default value into the DatePosted parameter in the sqldatasource object. I have put have the following below but it doesn't work. I have also tried  <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= Date.Now %>" /> <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= now() %>" /> I know the solution is probably simple and I look like an idiot, but excuse me because I am very knew and fragile at this lol... any help would be great :). Mike. 

View 7 Replies View Related

Problem With Making A Sqldatasource For Inserting Using The Query Builder

Aug 19, 2007

I want to make a sqldatasource to insert data ito a table with values from textfields page. I want to use the sqldatasource programically (not bind it to a formcontrol).
I drag a sqldatasource from the toolbox to the design surface and start configuring the datasource. I spesify a custom sql statement, select the "Insert" tab and insert the table I want to store into the builder. Then I select the fields and the values (parameters from tue textfields. I test it with the "Execute query" button and the results is stored in the table. (everything seems ok) I press the "OK" button but both the "Next" and "Finish" buttons are dissabled, o I can not store the query.
What is going wrong. Can someone please help me ?
Tom Knardahl

View 2 Replies View Related

Error Inserting UserId In Codebehind Using SqlDataSource.insert()

Feb 9, 2006

I have a database with columnsuserOwnListsuserID uniqueidentifieruserName nvarchar100userList nvrachar100createdDateI
have created successfully a gridview controller to edit these values in
database. The Gridview data is populated by SqlDataSource.I
have also created a EmptyDataTemplate  and created a form into it.
There is only one textBox and submit button to create the First entry
to userOwnLists -table.Now I collect the value from EmptyDataTemplate textbox with id userList1 and create a codebehind logic for the submitbutton.protected void Button2_Click(object sender, EventArgs e)    {        TextBox listName = (TextBox)this.FindControl("listName1", GridView1.Controls);SqlDataSource1.InsertParameters["userId"].DefaultValue = Membership.GetUser().ProviderUserKey;        SqlDataSource1.InsertParameters["userName"].DefaultValue = Membership.GetUser().UserName.ToString();        SqlDataSource1.InsertParameters["listName"].DefaultValue = listName.Text;        SqlDataSource1.InsertParameters["createdDate"].DefaultValue = DateTime.Now.ToString();        SqlDataSource1.Insert();    }The problem is now that I get error: Exception Details: System.Data.SqlClient.SqlException:
Implicit conversion from data type sql_variant to uniqueidentifier is
not allowed. Use the CONVERT function to run this query.OK.  So I Googled a bit and found this:http://scottonwriting.net/sowblog/posts/4690.aspxMy Question is: How do I convert userId so I can insert it to database successfully?This does not work:String userId = Membership.GetUser().ProviderUserKey.ToString();        SqlDataSource1.InsertParameters["userId"].DefaultValue = Convert.ToString(userId);

View 2 Replies View Related

Inserting TextBox Values To Database Using SqlDataSource.Insert Method

Oct 25, 2006

Hi, it is few days I posted here my question, but received no answer. Maybe the problem is just my problem, maybe I put my question some strange way. OK, I try to put it again, more simply. I have few textboxes, their values I need to transport to database. I set SqlDataSource, parameters... and used SqlDataSource.Insert() method. I got NULL values in the database's record. So I tried find problem by using Microsoft's sample code from address http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insert.aspx. After some changes I tried that code and everything went well, data were put into database. Next step was to separate code beside and structure of page to two separate files followed by new test. Good again, data were delivered to database. Next step: to use MasterPage, very simple, just with one ContentPlaceHolder. After this step the program stoped to deliver data to database and delivers only NULLs to new record. It is exactly the same problem which I have found in my application. The functionless code is here:http://forums.asp.net/thread/1437716.aspx I cannot find any answer this problem on forums worldwide. I cannot believe it is only my problem. I compared html code of two generated pages - with maserPage and without. There are differentions in code in ids' of input fields generated by NET.Framework:Without masterpage:<input name="NazevBox" type="text" id="NazevBox" /><span id="RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="CodeBox" type="text" id="CodeBox" /><span id="RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="Button1" /> With masterpage:<input name="ctl00$Obsah$NazevBox" type="text" id="ctl00_Obsah_NazevBox" /><span id="ctl00_Obsah_RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="ctl00$Obsah$CodeBox" type="text" id="ctl00_Obsah_CodeBox" /><span id="ctl00_Obsah_RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="ctl00$Obsah$Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Obsah$Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_Obsah_Button1" />In second case ids' of input fields have different names, but I hope it is inner business of NET.Framework.There must be something I haven't noticed, maybe NET's bug, maybe my own. Thanks for any suggestion.

View 2 Replies View Related

Calculated Field Using Two Data Sets

May 12, 2008

Hi,

I'm trying to created a report.
Final report looks like this.







Total Loans/Lines (#)
13,283



Total Commitments ($ MM)
$1,703



Total Outstandings ($ MM)
$1,175







A
B
C
D
F

Bankruptcy
0
$0
$0
0.00%
0.00%

Charge Off
0
$0
$0
0.00%
0.00%


Source table looks like this;







Bankruptcy



0

Charge Off



0

CLTV
131

DSR
102

Exc Total
265

FICO
7

Foreclosure/Repossession

Grand Total
13283

Loan Amount
32


Column D = A Bankrupcy(0) / Total Loans/Lines #(13283)

But it does not let me to use report expression as its not in the same scope.

Can anyone tell me how to do this calculation ?I was trying to use a report expression but it seems like not working.

Thanks

View 15 Replies View Related

Inserting Datetime Through Sqldatasource - String Was Not Recognized As A Valid DateTime

Dec 6, 2006

I'm getting error:
String was not recognized as a valid DateTime.
my insert parameter: 
<asp:Parameter Name="LastModified" Type="DateTime" DefaultValue= "<%=DateTime.Now.ToString() %>"
my insert command:
InsertCommand="INSERT INTO [Product] ([Enabled], [ProductCode], [ProductName], [ProductAlias], [CarrierId], [DfltPlanId], [DoubleRating], [DoubleRateProductId], [ConnCharges], [StartDate], [EndDate], [Contracted], [BaseProductId], [LastModified], [LastUser]) VALUES (@Enabled, @ProductCode, @ProductName, @ProductAlias, @CarrierId, @DfltPlanId, @DoubleRating, @DoubleRateProductId, @ConnCharges, @StartDate, @EndDate, @Contracted, @BaseProductId, @LastModified, @LastUser)"
LastModified is a datetime field.
 Running sql2005

View 1 Replies View Related

Dynamic Data Set Based On Calculated Fields

Mar 26, 2008



Hi,

I have three data sets. Data Set A is bound to my table in my report. There are also Data Sets B and C. All three data sets have the identical columns. I have setup data set A so that all of its fields are "Calculated". The calculation for each field will either pick the field from data set B or data set C based upon a parameter called BorC. So the calcualted fields in data set A look like the following:


=iif(Parameters!BorC.Value, First(Fields!MyField.Value, "dataset_B"), First(Fields!MyField.Value, "dataset_C"))

Problem is when I run the report I get internal error. Is it possible to populate one data set from the fields of another data set? If so is there some trick to doing this? Stripping this example down to one column in each of the data sets, and then just directly setting data set A from either B or C still gives me the same error. SO I set the one field in data set A to the following and it still doesn't work:

=First(Fields!MyField.Value, "dataset_B")

OR

=First(Fields!MyField.Value, "dataset_C")

This leads me to believe there is some fundamental problem with using another data set in a Calculated field. Since I think I have done this before I am convinced I am doing sommething wrong.

Any advice you have for me would be greatly appreciated!

Thanks.

View 1 Replies View Related

Data Source Views - Calculated Columns

Feb 7, 2007

Q: How do I use Calculated Columns from a Data Source View in an OLEDB Data Source Adapter.

I took the following steps:

- Created new SSIS project
- Added a Data Source connecting to a SQLServer2005 DB (MyDataSource)
- Added a Data Source View based on MyDataSource (MyDSV)
- Created a Calcualted field to Table Object MyTable (MyCalcField)
- Added a Connection Manager based on MyDSV
- Added Data Flow to Project
- Added OLEDB Source Adapter to Data Flow
- Attempting to Access Calculated Field MyCalcField to be used in Data Flow.

ISSUE: I can't seem to find a way to get the Calculated field to pass through. It's as though this metadata is not available to the Flow.

Anyone have any ideas?

Thanks - MikeyNero

View 6 Replies View Related

SQL Server 2008 :: Data Type Of Calculated Fields

Aug 10, 2015

I'm using the SQL below to work out recruitment figures. The query works well, but I now need to build this query into a DotNet application as a webpage. I therefore need to declare and manipulate the values such as 'Total', 'Jan' to 'Dec' and 'YearRecruited' in order to write these values into my chosen data control. I therefore need to know the datatypes of these calculated values.

Total I think is straightforward as DNAScreeningID is an int datatype. But what about the others?

SELECT YEAR(SamplingDate) AS YearRecruited,

COUNT(CASE WHEN month(SamplingDate) = 1 THEN DNAScreeningID END) AS 'Jan',
COUNT(CASE WHEN month(SamplingDate) = 2 THEN DNAScreeningID END) AS 'Feb',
COUNT(CASE WHEN month(SamplingDate) = 3 THEN DNAScreeningID END) AS 'Mar',
COUNT(CASE WHEN month(SamplingDate) = 4 THEN DNAScreeningID END) AS 'Apr',

[Code] ....

View 5 Replies View Related

Adding A Calculated Field By Using Two Fields From Different Data Sets

Oct 1, 2007



Can I make a calculated field by using two fields from different data sets?(I'm talking about SSRS data sets)

I tried to do that. But I got a error message.




"Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope."


Please can some one help me out?

View 5 Replies View Related

Analysis :: Calculated Translated Measures - Underlying Data

Oct 7, 2015

I am trying to develop a cube with translated calculated measures in it. I have also translated the all underlying measures/dimensions being used in action for a header.

I can see my translated measures and dimension in excel but when I go to Underlying data, I see default member's names not the translated one. Please note that I have translated all underlying members.

View 4 Replies View Related

Power Pivot :: How To Add Calculated Fields To Every Query In Data Model

Nov 12, 2015

I have created 60 queries and added them to my data model in Power Pivot/Excel 2016. I created some calculated fields for one of my queries but I would LOVE to know how to just copy these across all queries in the data model instead of having to create them in the data model for one query at a time. That will take forever. 

View 3 Replies View Related

SQL 2012 :: Calculated Columns Conditional On Calculated Columns Multiple Tables

Apr 20, 2014

I have 4 tables involved here. The priority table is TABLE1:

NAMEID TRANDATE TRANAMT RMPROPID TOTBAL
000001235 04/14/2014 335 A0A00 605
000001234 04/14/2014 243 A0A01 243
000001236 04/14/2014 425 A0A02 500

TRANAMT being the amount paid & TOTBAL being the balance due per the NAMEID & RMPROPID specified.The other table includes a breakdown of the total balance, in a manner of speaking, by charge code (thru a SUM(OPENAMT) query of DISTINCT CHGCODE

TABLE2
NAMEID TRANDATE TRANAMT RMPROPID CHGCODE OPENAMT
000001234 04/01/2014 400 A0A01 ARC 0
000001234 04/05/2014 -142 A0A01 ARC 228
000001234 04/10/2014 15 A0A01 ALT 15

[code]...

Also with a remaining balance (per CHGCODE) column. Any alternative solution that would effectively split the TABLE1.TRANAMT up into the respective TABLE2.CHGCODE balances? Either way, I can't figure out how to word the queries.

View 0 Replies View Related

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

SQL Server 2012 :: Get Empty Data Set For Inserting Data?

Nov 11, 2014

I have 2 tables in my database.

one is Race table and 2nd one is Age Range.

I want to write a query where I can see all races and age range as column.

TblRace

ID, RaceName

TblAgeRange

ID,AgeRange.

There is no connection between this two table. I need to display result like below.

Race 17-20 21-30 31-40

A

B

I

W

How do i get this kind of empty data set so that I can fill it out in front end or any better solution. The age range will be displayed as many row as they have. It's not static. Above is just an example.

View 1 Replies View Related

Inserting The Data Into Text Data Type

Jan 22, 2001

Hi everybody,

In our datbase we have a table with text data type.Help me if anybody knows how to insert text data into text data type of sql server.

i am able to modify and retrive but i am not able to insert text. please if u have idea, please give me reply asap.

Thanks,
Giri

View 1 Replies View Related

Adding New Data Fiels And Inserting Data

Sep 17, 2004

I have some website work lined up and it involves some simple modifications to a MS SQL 2000 server. What I'll need to do is add some new data fields and insert some data.

I have some experience with databases - MS Access and MySQL, but I have never used or seen MS SQL 2000. My question is, is this a relatively simple thing to do for someone who hasn't used it before? I can do these things quite simply in Access or MySQL, so is MS SQL 2000 going to be any different?

Also, does anyone know of any free tutorials online that would help me out?

Thanks

View 1 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 Replies View Related

Re-use Data From SqlDataSource

Dec 11, 2006

I have a page containing a FormView, which gets its data from a SqlDataSource control and displays details of a job.  Two of the fields are location and job title.  I want to re-use this data to create a dynamic page title.  I know I can do this by setting the Page.Title to what I want to,  but do I have access to the data outside of the FormView to which the data source is bound?  If so how?   Or will I have to perform an additional SELECT statement to get this data again?

View 2 Replies View Related

Using The SqlDataSource To Get Data .net 2.0

Feb 14, 2006

I am used to using asp.net 1.1
and I want to do the equivilent of the following with an SqlDataSource


da.fill(dst1)
lbl.text=dst1.tablename(0).fieldname


and what this does is fills the dataset with the information from the select command in the dataadapter and then gets the value for the first row of the fieldname

It doesnt seem like this should be that big of a deal, but it has become very frustrating trying to find the answer, does anyone know how to do this? Please post some demo code if possible

View 2 Replies View Related

Using Data From SqlDataSource

Mar 9, 2006

Hi Everybody,I have an ordinary SqlDataSource on my page <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:P4SConnection %>"                ProviderName="<%$ ConnectionStrings:P4SConnection.ProviderName %>" SelectCommand="SELECT CO_Id,CT_Name,CO_Username,CO_Password,CO_Company,CO_Email,CT_Id,CT_Position,CT_Admin,                CO_Session,CO_LastLogin FROM company_contact LEFT JOIN company ON company_contact.CT_Company = company.CO_Id WHERE (CT_Username= & LCase(txtName.Text) & ">            </asp:SqlDataSource>How do i use any of these values?I know I can display the values in a GridView or something but I dont want to display them.I originaly was using ODBC and just used the followingDim Row As DataRow = thisTable.Rows(0)            Dim lP_ID As String = Row(0).ToString()            Dim TheContact As String = Row(1).ToString()            Dim theName As String = Row(2).ToString()            Dim thePassword As String = Row(3).ToString()            Dim TheCompany As String = Row(4).ToString()            Dim TheEmail As String = Row(5).ToString()            Dim lP_ContactID As String = Row(6).ToString()            Dim ThePosition As String = Row(7).ToString()            Dim bAdmin As Boolean = Row(8).ToString()            Dim sP_Session As String = Row(9).ToString()            Dim sP_Last As String = Row(10).ToString()Then I could use the values wherever I wanted.How do I do this with a SqlDataSource?Thanks,G

View 4 Replies View Related

Help On Inserting Data To DB

Sep 11, 2006

Hi,I m using Microsoft Visual Studio 2005 and SQL server 2000. I have 2 textboxes and a button, what i wanna do is, when i hit the button, the values in textboxes should be inserted into DB. Would you please help me? Thanks in advance.

View 1 Replies View Related

Inserting Data Into DB

May 5, 2007

Hi friends,I have one text box on my form.i need to insert the data from tat text box to DB without clicking on any button.Now i have written the code under text changed event of that text box.So it is inserting whenever i click on that form.Besides this i need to insert data when i close tat window.But it is not inserting when i close tat window.Plse help me.Thanks in advance
With RegardsLijo Rajan

View 1 Replies View Related

Inserting Data

Jun 6, 2007

I have created a form with several fields etc and validation.

After pressing the submit button i have a

if Page.IsValid then .....etc
But in this then bit I want to do a

INSERT the form details to the db.

I have done inserts etc via gridView etc but I just need a form that lets someone enter info and submit etc, so do not now where to or how to place this code to connect then insert etc

thanks

View 3 Replies View Related

Inserting Data To SQL

Dec 6, 2005

Hi all,
 
I'm having a problem saving the information from my web form into my sql database when I clicked on the 'Submit' button.
This is the error message
 Server Error in '/Helpdesk' Application.




ExecuteNonQuery: Connection property has not been initialized.
I've attached my code below. Please advise me on what is wrong... How should I initialise the ExecuteNonQuery.
========= start code ====================
Dim MySQL As String
MySQL = ""
Dim MyConn As SqlConnection = New SqlConnection()
Dim MyCmd As SqlCommand = New SqlCommand()
MyConn.ConnectionString = "Server=ESAWEB2;Database=Helpdesk;Trusted_Connection=True;"
MySQL = "INSERT INTO TBL_TROUBLE_TICKET (Priority) values (' ddlpriority ')"

MyConn.Open()

MyCmd.ExecuteNonQuery()
MsgBox("Record Inserted")
=======end code ===============

View 1 Replies View Related

Need Help Inserting Data!!

Mar 27, 2006

I am not looking for free code but this is driving me out of my mind. I'm a pretty proficient PHP programmer and have been dealing with a form that I was made to program in ASP.Net due to my employer's preferences. I can't attach the code for the form so I have cut and pasted it below. I am needing to know whow do I code this so that the data will go into a MS SQL 2005 database? I already have some coding in it but I don't know if it's correct and any help in getting this fixed would be great as it is slowly driving me up the wall. Thanks!
 
  <%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conebackups As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand

conebackups = New SqlConnection("Server=localhost;UID=sa;pwd=kitten33;database=ebackups")
strInsert = "INSERT cust_info ( cust_name, cust_contact, cust_phone, cust_analyst, install_date, cust_username, cust_password, account_request_type, quickbooks_check, peachtree_check, mssba_check, goldmine_check, act_check, mail_info, db_info, mapped_info, mobile_data, mail_option, db_option, mapped_option, mobile_option, backupexec_option ) Values ( 'cust_name, 'cust_contact', 'cust_phone', 'cust_analyst', 'install_date', 'cust_username', 'cust_password', 'account_request_type', 'quickbooks_check', 'peachtree_check', 'mssba_check', 'goldmine_check', 'act_check', 'mail_info', 'db_info', 'mapped_info', 'mobile_data', 'mail_option', 'db_option', 'mapped_option', 'mobile_option', 'backupexec_option' )"
cmdInsert = New SqlCommand(strInsert, conebackups)
conebackups.Open()
cmdInsert.ExecuteNonQuery()
conebackups.Close()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Weston Backup Questionnaire</title>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<form id="westonquest" runat="server">
<div>
<div style="border-left-color: black; border-bottom-color: black; border-top-color: black;
text-align: center; border-right-color: black" title="Weston Backup Questionnaire">
<table>
<tr>
<td colspan="3" style="width: 540px; height: 30px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">Weston Online Backup Questionnaire</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 10px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Please fill out the following information
as accurately as possible. Any incorrect information may affect the customers online
backup in a serious manner. All of the following fields require an answer before
you can submit the form.<br />
</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px">
<br />
<span style="font-size: 14pt; font-family: Verdana">Customer and Analyst Information</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Customer Name:<br />
</span>
<asp:DropDownList ID="cust_name" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="232px" DataSourceID="SqlDataSource1" DataTextField="cust_name" DataValueField="cust_name">
<asp:ListItem>Select Customer Name.....</asp:ListItem>
<asp:ListItem Value="WestonANC">Weston - ANC</asp:ListItem>
<asp:ListItem Value="WestonBND">Weston - BND</asp:ListItem>
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ebackupsConnectionString %>"
SelectCommand="SELECT [cust_name] FROM [backup_info]"></asp:SqlDataSource>
<span style="font-size: 8pt; font-family: Verdana">
<br />
<br />
Customer Contact:                  
                  Customer Phone Number:<br />
<asp:TextBox ID="cust_contact" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="190px"></asp:TextBox>
              <asp:TextBox ID="cust_phone"
runat="server" Font-Names="Verdana" Font-Size="X-Small" Width="146px"></asp:TextBox><br />
<br />
Analyst:                      
                       
      Today's Date: (mm/dd/yyy format)<br />
<asp:DropDownList ID="cust_analyst" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="162px">
<asp:ListItem>Select Analyst.....</asp:ListItem>
<asp:ListItem>Brock McFarlane</asp:ListItem>
<asp:ListItem>Cameron Farrally</asp:ListItem>
<asp:ListItem>Eric Spinney</asp:ListItem>
<asp:ListItem>Greg Freeman</asp:ListItem>
<asp:ListItem>Kevin Mark</asp:ListItem>
<asp:ListItem>Mark Anderson</asp:ListItem>
<asp:ListItem>Mike Murphy</asp:ListItem>
<asp:ListItem>Tim Elder</asp:ListItem>
</asp:DropDownList>
                      
<asp:TextBox ID="install_date" runat="server" Font-Names="Verdana" Font-Size="X-Small"></asp:TextBox><br />
<br />
Customer E-Backup Username:                
  Customer E-Backup Password:<br />
<asp:TextBox ID="cust_username" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="150px"></asp:TextBox>
                         <asp:TextBox ID="cust_password" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="150px" TextMode="Password"></asp:TextBox><br />
<br />
<asp:RadioButtonList ID="account_request_type" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="430px">
<asp:ListItem Value="New">New Account</asp:ListItem>
<asp:ListItem Value="Change">Account Change</asp:ListItem>
<asp:ListItem Value="Delete">Account Deletion</asp:ListItem>
</asp:RadioButtonList></span><br />
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center;">
<span style="font-size: 14pt; font-family: Verdana">Financial / CRM Programs</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer use any of the
following financial / CRM products?<br />
<br />
Quickbooks<asp:CheckBox ID="quickbooks_check" runat="server" />
         Peachtree Accounting<asp:CheckBox ID="peachtree_check"
runat="server" />
         MS Small Business Acct<asp:CheckBox ID="mssba_check"
runat="server" />
        
<br />
Sage Goldmine<asp:CheckBox ID="goldmine_check" runat="server" />
         Sage ACT!<asp:CheckBox ID="act_check" runat="server" /><br />
<br />
<br />
</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">BackupExec / NTBackup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer use BackupExec,
NTBackup or any other backup software? </span><span style="color: #ff0066"><span
style="font-size: 8pt; font-family: Verdana">(Important!)<br />
<br />
</span>
<asp:RadioButtonList ID="backupexec_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
ForeColor="Black" RepeatDirection="Horizontal" Width="127px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList></span><span style="font-size: 8pt; font-family: Verdana">If "Yes"
which program do they use for backups?  <asp:TextBox ID="backup_program" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Width="200px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">Mail Server Backup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer want to backup
their E-Mail system?<br />
<br />
</span>
<asp:RadioButtonList ID="mail_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="127px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" what
e-mail server software does the customer use?
<asp:TextBox ID="mail_info" runat="server" Font-Italic="False" Font-Names="Verdana"
Font-Overline="False" Font-Size="X-Small" Width="171px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Database Backup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 30px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer have a SQL, Access
or other RDMS that they wish to have backed up?<br />
<br />
</span>
<asp:RadioButtonList ID="db_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="128px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" please
list the databases the customers needs to have backed up.<br />
<asp:TextBox ID="db_info" runat="server" Height="102px" Width="321px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Network Drives</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt"><span style="font-family: Verdana">Does the customer want
any shared or mapped drives backed up? </span><span style="color: #ff0066"><span
style="font-family: Verdana">(Important!)</span><span style="color: #000000"><span
style="font-family: Verdana">
<br />
<br />
</span>
<asp:RadioButtonList ID="mapped_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="126px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList></span></span></span><span style="font-size: 8pt; font-family: Verdana">If
"Yes" please list the mapped or network drive the customer wishes to backup.<br />
<asp:TextBox ID="mapped_info" runat="server" Height="101px" Width="321px"></asp:TextBox><br />
<br />
</span>
</td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Mobile Users</span></td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer have mobile users
that they wish to have data backed up for?<br />
<br />
</span>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="121px">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" please
enter the username and machine name for mobile user as well as when they will be
in the office for remote install of software.<br />
<asp:TextBox ID="TextBox1" runat="server" Height="101px" Width="321px"></asp:TextBox><br />
<br />
</span>
</td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<asp:Button ID="Button" runat="server" Text="Submit Form For Processing" /></td>
</tr>
</table>
</div>

</div>
</form>
</body>
</html> 

View 5 Replies View Related

Inserting Data PK/FK

Feb 18, 2006

I'm trying to insert a record into a master table, but b/c of the foreign key relationship, I know that I need to first insert a record into the child table so I don't get a foreign key error. The problem is that the record that I'm inserting doesn't have any columns that match up (similar)to the child table, and only a few that match up to the master table.

View 3 Replies View Related







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