How To Progtammatically Manipulate Property 'Name' Of ControlParameter?

Jun 7, 2007

Hi,

i want to programmatically manipulate the property 'Name' of a
ControlParameter inside a InsertParameters tag.


This the aspx code:
------------------
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%
......... %>"
        InsertCommand="INSERT INTO .......)"
           <InsertParameters>
           <asp:ControlParameter Name="myname" ControlID="na"
PropertyName="text" />
          </InsertParameters>
        </asp:SqlDataSource>


code-behind:
------------


Dim a As String
        a = SqlDataSource1.InsertParameters.Item(0).ToString


but 'm stuck here


Thanks for help

Tartuffe

View 1 Replies


ADVERTISEMENT

ControlParameter

Jan 23, 2008

I am new to asp.net and this is the first time I have tried to use a ControlParameter from another control and I can not get it to work. FormView1 works as expected, but the controlParameter in SqlDataSource2 does not work as expected.
 A part of FormView1 and SqlDataSource1 (the source)<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id"
DataSourceID="SqlDataSource1"
<ItemTemplate>
<asp:Label ID="lblCategoryName" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Id], [CategoryName], [ItemNumber], [Name], [Price], [SalePrice], [FullDescription], [ImageAltText], [DateSold] FROM [Products] WHERE ([Id] = @Id)">
<SelectParameters>
<asp:QueryStringParameter Name="Id" QueryStringField="Id" DefaultValue="11" />
</SelectParameters>
</asp:SqlDataSource>
 
SqlDataSource2 (where I need to use "lblCategoryName" from FormView1) <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Id], [CategoryName], [ImageAltText], [DateSold] FROM [Products] WHERE ([CategoryName] = @CategoryName)">
<SelectParameters><asp:ControlParameter ControlID="FormView1"
DefaultValue="Earrings" Name="lblCategoryName"
PropertyName="text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I hope someone can help me with my simple problem.
Thank you

View 1 Replies View Related

How To Add ControlParameter To SqlDataSource At Runtime?

Dec 8, 2006

Hi!
My question is exactly the subject.
My Web Form has only a GridView and a DetailsView, there is no SqlDataSource at project time, i create the SqlDataSource at runtime using code like this in the Page_Load event: (I NEED IT TO BE CREATED DYNAMICALLY)1 Dim SQLDS As SqlDataSource = New SqlDataSource()
2
3 SQLDS.ID = "CustomerDataSource"
4 SQLDS.ConnectionString = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
5 SQLDS.SelectCommand = "select customerid,companyname,contactname,country from customers"
6 SQLDS.InsertCommand = "insert into customers(customerid,companyname,contactname,country) values(@customerid,@companyname,@contactname,@country)"
7 SQLDS.UpdateCommand = "update customers set companyname=@companyname,contactname=@contactname,country=@country where customerid=@customerid"
8 SQLDS.DeleteCommand = "delete from customers where customerid=@customerid"
9
10 SQLDS.UpdateParameters.Add(New Parameter("companyname"))
11 SQLDS.UpdateParameters.Add(New Parameter("contactname"))
12 SQLDS.UpdateParameters.Add(New Parameter("country"))
13 SQLDS.UpdateParameters.Add(New Parameter("customerid"))
14
15 Page.Controls.Add(SQLDS)
16
17 If Not Page.IsPostBack Then
18 GridView1.DataKeyNames = New String() {"customerid"}
19 GridView1.DataSourceID = SQLDS.ID
20
21 ' ... and so on
The DetailsView1 uses the same SqlDataSource to show data, but i could not find a way to synchronize the DetailsView1 with the GridView1 when a record is selected in the GridView1.How can I synchronize the DetailsView?I played with the ControlParameter but i can't find either how to add a ControlParameter in code, is there a way? Every place talking about ControlParameter shows something like this: 1 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
2 ConnectionString="<%$ ConnectionStrings:Pubs %>"
3 SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE [state] = @state">
4 <SelectParameters>
5 <asp:ControlParameter Name="state" ControlID="DropDownList1" PropertyName="SelectedValue" />
6 </SelectParameters>
7 </asp:SqlDataSource>
8
 Ok. OK. But my SqlDataSource is created dynamically. Any ideas on how to solve this problem?Thanks!

View 3 Replies View Related

Set ControlParameter To Todays Date (vb)

Dec 21, 2006

Hi,I have the following sqldatasource on my page:<asp:SqlDataSource ID="rs1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>" SelectCommand="Proposals_DaySheet" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter ControlID="Calendar1" Name="FilterDate" PropertyName="SelectedDate" Type="DateTime" DefaultValue=""/></SelectParameters></asp:SqlDataSource>How do I set the default value to today's date ?I have tried:DefaultValue="<%# DateTime.Now %>"But I get:Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ControlParameter does not have a DataBinding event.I have also tried:DefaultValue="<%= DateTime.Now %>"But I get:System.FormatException: String was not recognized as a valid DateTime.Any ideas ?ThanksJames
 

View 4 Replies View Related

How To Specify 2 Different Selectparameters - 1 For Querystringparameter And 1 For Controlparameter

Apr 4, 2007

Hello,
I am sure there is a way to do this programmatically, but it is just not sinking in yet on how to go about this.  I have a page where I use a dropdownlist that goes into a gridview and then the selected item of the gridview into the detailsview (typical explain seen online).  So, when selecting from the dropdownlist, the gridview uses a controlparameter for the selectparameter to display the appropriate data in the gridview (and so on for the detailslist). 
My question is - I wanted to use this same page when coming in from a different page that would utilize querystring.  So, the parameter in the querystring would be for what to filter on in the gridview, so the dropdownlist (and that associated controlparameter) should be ignored.
Any suggestions on how to go about this?  I assume there is some check of some sort I should in the code (like if querystring is present, use this querystringparameter, else use the controlparameter), but I am not sure exactly what I should check for and how to set up these parameters programmatically.
 Thanks,
Jennifer

View 5 Replies View Related

SqlDataSource+ControlParameter+Textbox

Jan 15, 2008

Hi!
I have a page (a search page) with sqldatasource, gridview and set of textboxes. The sqldatasource is using stored procedure with parameters. Using the visual wizard i'm associating the parameters with apropriate textboxes controls. It all works, like a charm.
The problem arises when I input some dangerous code in any textbox , like ' or % .
I'm having exception about unenclosed strings, generally info about the possibility of sql injection.
I thought that using ControlParameters, any Parameter in fact is sqlinjection safe, but apparently it isn't.
Does anyone know the right way of achieving my goal? It's very urgent.

View 7 Replies View Related

ControlParameter And Stored Procedures

Apr 2, 2006

I'm sure I'm missing something silly.  I have 3 textboxes, a stored procedure and a gridview.  The user will put something in the 3 boxes, click submit, and see a grid with stuff (I hope).  However, the grid will only return data is I EXCLUDE the controlparameters and only use the sessionparameter.  It's like the stored proc won't even fire!
HTML:
<form id="form1" runat="server"><div>Lastname:&nbsp;<asp:textbox id="Lastname" runat="server"></asp:textbox>Hobbies:&nbsp;<asp:textbox id="Hobbies" runat="server"></asp:textbox><br />Profession:&nbsp;<asp:textbox id="Profession" runat="server"></asp:textbox><asp:button id="Button1" runat="server" text="Button" /><br /><asp:gridview skinid="DataGrid" id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1"><columns><asp:boundfield datafield="Username" headertext="Username" sortexpression="Username" /><asp:boundfield datafield="Lastname" headertext="Lastname" sortexpression="Lastname" /><asp:boundfield datafield="Firstname" headertext="Firstname" sortexpression="Firstname" /></columns></asp:gridview>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:HOAConnectionString %>"selectcommand="spAddressBookSelect" selectcommandtype="StoredProcedure"><selectparameters><asp:sessionparameter defaultvalue="0" name="CommunityID" sessionfield="CommunityID" type="Int32" /><asp:controlparameter controlid="Lastname" name="Lastname" propertyname="Text" type="String" /><asp:controlparameter controlid="Profession" name="Profession" propertyname="Text" type="String" /><asp:controlparameter controlid="Hobbies" name="Hobbies" propertyname="Text" type="String" /></selectparameters></asp:sqldatasource>
</div>
</form>
sp signature:ALTER PROCEDURE [dbo].[spAddressBookSelect] @CommunityID int = 0,@Lastname varchar(200) = NULL,@Profession varchar(200) = NULL,@Hobbies varchar(200) = NULL

View 2 Replies View Related

Changing Code Page Property Using Property Expression Doesn't Work

Jun 16, 2006

I am having problems exporting data into a flat file using specific code page. My application has a variable "User::CodePage" that stores code page value (936, 950, 1252, etc) based on the data source. This variable is assigned to the CodePage property of desitnation file connection using Property expression.

But, when I execute the package, the CodePage property of the Destination file connection defaults to the initial value that was set for "User:CodePage" variable in design mode. I checked the value within the variable during runtime and it changes correctly for each data source. But, the property of the destinatin file connection doesn't change and results in an error.

[Flat File Destination [473]] Error: Data conversion failed. The data conversion for column "Column01" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

[DTS.Pipeline] Error: The ProcessInput method on component "Flat File Destination" (473) failed with error code 0xC02020A0. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.

If I manually update the variable with correct code page and re-run the ETL, everything works fine. Just that it doesn't work during run-time mode.

Can someone please help me resolve this.

Thanks much.

View 5 Replies View Related

Value Of A Readonly Property Of Custom Task Is Not Updated In Property Window

Apr 17, 2008

Hi,

I developed a simple custom control flow component which has several read/write properties and one readonly property (lets call it ROP) whichs Get method simple returns the value of a private variable (VAR as string). In the Execute method the VAR has a value assigened. When I put the value of ROP or VAR into MsgBox I can see the correct value. However when I execute the component I can not see the value of the ROP in the property window. I see the property but its value is empty string. For example when I put a breakpoint to postexecute or check the property before click OK in a MsgBox I would expect that the property value would be updated in SSIS as well. Is there a way how to display correct values of custom tasks properties in property window?

Thanks for any hints.

View 3 Replies View Related

Load ControlParameter From Page's Peoperties

Feb 25, 2008

Hi,in aspx I've SqlDataSource, in SelectParametersI can add ControlParameter and to load parametersfrom control Property, BUT I'm trying to do that:Is there way, when in <ControlParameter>to set parameter to be loaded from PAGE Property.something like that:aspx:<asp:SqlDataSource ID="_companyDS" runat="server"   ConnectionString="<%$ ConnectionStrings:tihomir_dbConnectionString %>"   SelectCommand="SELECT [companyID], [companyName], [companyInfo], [companyAddress] FROM [Companies] WHERE ([companyID] = @companyID)">   <SelectParameters>     <asp:ControlParameter ControlID="Page" PropertyName="CompanyIdent" Name="companyID" Type="Int32" DefaultValue="0" />   </SelectParameters>    </asp:SqlDataSource></asp:SqlDataSource>code behind:public partial class test : System.Web.UI.Page{   public int CompanyIdent   {      get      {         return ... some id ...;      }   }}  Best Regards,Tihomir Ivanov Best Manager Software

View 2 Replies View Related

(URGENT) Cannot Be Written To The Property. The Expression Was Evaluated, But Cannot Be Set On The Property

May 7, 2008

Untill recently I had a smooth running SSIS package,but suddenly it throws error syaing
"OnError,,,,,,,The result of the expression

"@[User:trTextFileImpDirectory] +"SomeTextStringHere"+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ "SomeTextStringHere"
" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property."

I have child SSIS package running under a parent package (through execute package task)

I have few flat file connection managers in child package for text file import , in which I am building text file path dynamically at run time by assigning an expression in connection string property of connection manager.
The Expression is as follows



"@[User:trTextFileImpDirectory] +"SomeTextStringHere."+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ +"SomeTextStringHere"

Where @[User:trTextFileImpDirectory] is a variable which contains path of directory containg text
files.Value in this variable is assigned at runtime from parent package's variable,which in turns fetch
value from a configuration file on local server.

With my current configuration this path has been configured to some other server's directory over network ( I.e my package picks text files from some other servers folder over network)

While
"Some string here"+ @[User:trANTTextFileName]" part of file name string.

(DT_STR,30,1252) @[User:taging_Date_Key] Contain the date of processing ,value in this variable is also picked up at run time from parent package variable.

1) So can someone give me some insight into possible reason of failures.
2) Is it possible that problem arises if directory (from which I m picking text files) is assigned password or is there exist some problem in accessing forlders over network ?
3) Or there can be some problem in package configuration at design time( I.e where I m assigning value in variable from parent package vriables)?




View 10 Replies View Related

Sending Multiple Values From A ListBox To ControlParameter

Dec 15, 2005

Any ideas on how I can send multiple values from a listbox to a stored procedure?  right now I have a ListBox Control called lbCategory, and I want to pass multiple selected items to a stored procedure.  
<asp:SqlDataSource ID="dsFS" runat="server" ConnectionString="someConnectionString" SelectCommand="usp_FS" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lbCategory" DefaultValue="%" Name="category" PropertyName="SelectedValue" type="String" />
</SelectParameters>
</asp:SqlDataSource>

View 5 Replies View Related

Can A ControlParameter Be Used To Supply A Parameter For A Stored Procedure?

Apr 13, 2006

The code below is an attempt at using the value from a dropdownlist to feed into stored procedure outlined in the Select command. I have seen examples where the control parameter is used with a select command but nothing where the parameter has to be fed into a stored procedure.
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=".."SelectCommand="procCAGetCustomerKPIs" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter Name="iCustomerGroupId" ControlID="CustomerFilterList" PropertyName="SelectedValue" /></SelectParameters></asp:SqlDataSource>
 
cheers-jim.

View 2 Replies View Related

How To Manipulate Dates

Aug 4, 1999

Is there a way to manipulate a date variable into a specific month and day?? For example, I want whatever date the user will enter to be
changed to June 30 of the following year. So, if the variable @date is 12/12/1999, I want to change it to 6/30/2000. If the date
is 2/1/2001, I want to make it 6/30/2002

I can't use DateAdd because you need to know how many months to add or days to add. Basically, how do I retain the month and day while changing the year
the year based on a dynamic field. What I need is a DateChange function that is DateChange(mm, @month, @date) ? Is there
something like that?

Thanks,
Joyce

View 2 Replies View Related

Help Manipulate Strings

Aug 1, 2007

Hey everyone,

So I'm querying from a database where one of the fields for each entry is a city. I would like to count the ones in each city. So I'm counting and grouping on city. Unfortunately, the data is not very consistent. Some are listed as Miami, FL and others simply as Miami. I don't need the state so I can just drop it, but I can't figure out how. I was using charindex and substring, but can't get it to work because if there is no ',' then the charindex is zero and substring doesn't work correctly. Any help would be greatly appreciated.

Thanks,
Keith

View 1 Replies View Related

Passing Parameters To SQL Stored Procedure With SQLDataSource And ControlParameter

Mar 28, 2007

Hello,
I'm having trouble executing a Stored Procedure when I leave the input field empty on a 'search' criteria field. I presume the error is Null/Empty related.
The Stored Procedure works correctly when running in isolation. (with the parameter set to either empty or populated)
When the application is run and the input text field has one or more characters in it then the Stored Procedure works as expected as well.
 
Code:
.
.
<td style="width: 3px">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="LogId" DataSourceID="SqlDataSource1"
Width="533px">
<Columns>
<asp:BoundField DataField="LogId" HeaderText="Log Id" InsertVisible="False" ReadOnly="True"
SortExpression="LogId" />
<asp:BoundField DataField="SubmittedBy" HeaderText="Submitted By" SortExpression="SubmittedBy" />
<asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" />
<asp:TemplateField>
<ItemTemplate>
<span>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink></span>
</ItemTemplate>
</asp:TemplateField>
 
</Columns>
<HeaderStyle BackColor="#608FC8" />
<AlternatingRowStyle BackColor="#FFFFC0" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SmallCompanyCS %>"
SelectCommand="spViewLog" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="txtName" ConvertEmptyStringToNull="true" Name="name" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
Stored Procedure:
ALTER PROCEDURE dbo.spViewLog (@name varchar(50) )
 
AS
SELECT * FROM log_Hdr WHERE (log_hdr.submittedby LIKE '%' + @name + '%')
RETURN
 
I have tried the 'convertemptystringtonull' parameter but this didn't seem to work.
 Any guidance would be much appreciated.
Thank you
Lee
 
 

View 2 Replies View Related

Manipulate Various Databases With Only One Connection

Jan 10, 2007

hi guys.
i want to know if is it possible to connect various databases with only one connection?
thx.

View 6 Replies View Related

Manipulate Data Within Table

Apr 12, 2005

Hil,

I posted a thread here: http://forums.devshed.com/showthread.php?p=1061405 but was told it might be more useful for me to post something here... should have thought about it to begin with!

The picture is in that thread so do please look at it! http://forums.devshed.com/attachmen...tachmentid=7431 should be the URL.

As you see the top 3 records start and finish at the same time, as do the last 3 records. This can then also be repeated for the next day etc etc. What I want to happen is that the top 3 courses to appear on a single line and the 2nd set of 3 to appear on a single line also.

The main SQL to retrieve the records is as follows:
Code:

sqlqry = "SELECT * FROM t_sessions a INNER JOIN t_session_times b ON a.session_id = b.session_ID"
sqlqry = sqlqry & " WHERE right(left(convert(varchar,a.session_date,113),11),8)='"+displaym +"'"
sqlqry = sqlqry & " AND a.session_supplier_id=61"
sqlqry = sqlqry & " AND a.session_status ='A'"
sqlqry = sqlqry & " ORDER BY a.session_date, b.session_start, b.session_end"

then while this recordset hasn't come to an eof(end of file) I execute:
Code:

query = "SELECT course_name,outline_name"
query = query & " FROM t_course_ref"
query = query & " LEFT JOIN t_it_outlines ON t_course_ref.course_id=t_it_outlines.course_id"
query = query & " WHERE t_course_ref.course_id="+cstr(rs.fields(1).value)

Thanks!

View 5 Replies View Related

How To Manipulate An User Mdf File

Nov 14, 2006

I remember I was able to view, add, alter table on the mdf in either sql express 2005 or in vb.net 2005. But right now I can't do either, what do I have to to change

View 1 Replies View Related

How Manipulate A DataSet That SqlDataSource Return

Apr 21, 2008

hi,I have a page Price List  with GridView to display only two columns of a table (Product name & price). Page size=20.  I use SqlDataSource  for  it. <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"In my case the SqlDataSource control return data as a DataSet object. So the DataSet object contains all the data in server memory. I need to create Print Preview page with other columns (Product name & price & Vendor and  Date Issue) without paging.I'm going to save dataSet in Session and in Print Preview page use it as datasource (without having to run another query).But I have no idea how to save this DataSet in Session. I don't know the DataSet Name. Any ideas?  Thanks.

View 2 Replies View Related

What Functions To Manipulate Numbers And Decimals

Oct 15, 2006

what re the sql functions to manipulate numbers, decimals, dates..
1/ like if I have 123443.78654 I want to display just 2 decimals : 123443.78 or 3 decimals ..
2/ also if I want to have bankers rounding
3/ how about dates conversion : from string to date type and vice versa and adding dates, substracting dates, getting the day, the month....
what re the SQL functions to do that pls

View 4 Replies View Related

Manipulate Data Without Using Temp Tables?

Dec 5, 2007

Good morning, everyone. Maybe I'm just having a brain fart, but I'm totally new to SSIS (I dabbled very little with DTS in the 2000 days) and cannot for the love of me figure out how to achieve my goal with it:

My company needs to extract data from a variety of sources; tab-delim files, Access databases, other SQL tables and the like. I know how to do this. However, I need to perform data manipulation queries on this data before I place them into SQL tables, as I want to avoid having umpteen temporary tables that I'll need to add checking for. My predecessor did everything in Access, and has a 76-step process (yikes!) that basically will grab all the data, do some minor manipulation, and plop it into a temp table (this is still in Access, not SQL), then repeat the same thing dozens of times.

To give you an example, here's a sample of what I want to do:

- Extract several columns of data from a tab-delimited file on the local drive. This I know how to do already.
- Perform some data cleanup and manipulation functions on this data (specifically, obtain the lowest value out of three columns, with the added caveat that I make sure it's not zero to begin with). I have the SQL code for this already written.
- Store the results of this data somewhere, so I can pull it and apply additional logic to it; for example, take the lowest value I've retrieved, and update the corresponding column in another database table with it.

Basically, is there any way to avoid the use of dozens of temp tables? There's a lot of data which needs to be pulled in, manipulated, and spit back out to be manipulated by something else a little later on, and the way my predecessor did it was, as I said, to use dozens of Access "Make Table" queries for every minor thing. It's not a big deal if I need to do it, just I'm trying to consolidate the steps needed, as the old way is very inefficient. I've been at this job a month and I'm still trying to wade through all of his queries to discover just what they do, and look into combining several of them.

Forgive the slightly newbish question, but as I stated I've not worked with SSIS really. I'm in the process of learning it better, as I'm sure it can fit our needs.

View 5 Replies View Related

How To Manipulate String In Query And Create New Field

Dec 22, 2006

I'm very new to SQL server and can use some help. MyTable has ColumnA, which contains strings composed of 1 to 4 numeric characters (0 thru 9) followed by alphabetic characters. For example, "53ASDF". In my query, I need to create ColumnB, which takes the numeric prefix from ColumnA's string and prepends it with zeros, if necessary, to create a string of exactly 4 numeric characters. For example, I could get the following result:

ColA ColB
"6abc" "0006"
"457def" "0457"
"7232hij" "7232"

I have implemented a temporary solution using a CASE statement:
SELECT ColA, ColB =
CASE
WHEN ISNUMERIC(LEFT(ColA, 4)) = 1 THEN (LEFT(ColA, 4))
WHEN ISNUMERIC(LEFT(ColA, 3)) = 1 THEN '0' + (LEFT(ColA, 3))
WHEN ISNUMERIC(LEFT(ColA, 2)) = 1 THEN '00' + (LEFT(ColA, 2))
WHEN ISNUMERIC(LEFT(ColA, 1)) = 1 THEN '000' + (LEFT(ColA, 1))
ELSE ''
END
FROM MyTable


Because of additional complexities, I need to implement the solution with a loop instead of a CASE statement. Can someone please describe such a solution?

I'm very confused about how variables work in SQL Server, but made an attempt to implement a solution. Hopefully, someone can make corrections and describe how to use it with a SELECT statement. I would greatly appreciate any suggestions. This is what I started with:

DECLARE @ColBstring char(4)
DECLARE @num int
SET @ColBstring = ''
SET num = 1;
-- Get the numeric prefix from ColumnA's string
WHILE(isnumeric(substring(colA, 1, num)) = 1)
@ColBstring = (substring(colA, 1, num)
num = num + 1

-- Prepend the ColumnB string with zeros
WHILE(LEN(@ColBstring) < 4)
@ColBstring = '0' + @ColBstring


Thanks for any help,
Mike

View 1 Replies View Related

Unable To Manipulate The Xsl Output Encoding Type.

Feb 7, 2007

After generating one of my reports, I process the XML output through an XSLT stylesheet and export it to a text file. The issue is that after the export, the generated output text file begins with the special Byte-Order-Mark marker "EF BB BF" standard to Unicode files encoded in UTF-8, UTF-16 or UTF-32. I have explicitly set the attributes of the xsl output element to <xsl:output encoding="us-ascii" media-type="text/plain" method="text">, but it seems as though those are ignored when the output file is written. I cannot have these characters, because I am generating a fixed-width file for input into a legacy system.

Any suggestions or thoughts on what is causing the BOM to be written to my file, even though I have set the encoding to be different than UTF-8?

View 1 Replies View Related

Manipulate The 'deleted Record' Flag On DBF Files

May 7, 2007

Hi,



I am using OLE DB provider for Foxpro (VFPOLEDB.1) to query DBF files. I need to migrate the content of these files to a SQL Server 2005 database.



These DBF files have some (actually a lot) records marked as deleted using the DBF 'deleted' flag. When I submit a SELECT command to the OLE DB Provider, it returns me all the non-deleted records from the file.



It is very Ok as long as the 'deleted' rows actually have no more business value, but in my case, I need to do some processing on them, and even to migrate their data.



What are the options available for me to be able to query and differentiate the 'deleted' records ?



Thank you in advance,



Bertrand Larsy

View 6 Replies View Related

User Defined Data Types - Manipulate

Mar 4, 2008

I have somw tables like Product, Sales, Customer.

I used UDTs like ProductCode = nvarchar(30)
CustomerCode= nvarchar(15)
How can I modify my UDTs ?Is there any quick way for that ?


****

Thanks.

View 3 Replies View Related

Integration Services :: Derived Column Expression - Manipulate Data

Jun 4, 2015

I have one column CandidatePlaced (Data type Boolean).

Using data conversion i changed data type to DT_WSTR and then i used derived column to manipulate the data. Ex. 1 = "Yes" and 0 = "No"

[Candidate Placed ?] == "1" ? "Yes" : "No"

But at end of result i got all the columns as No. Some should be Yes.

View 7 Replies View Related

ActiveX Script In A SSIS Package - Calling An FSO To Create/manipulate Files

Jul 3, 2007

I have a SQL2000 DTS package that executes vbscript to loop through a recordset which:

- runs a stored procedure and populated tables

- builds a recordset from the populated tables to write records to an Excel file

- writes status to text files with either the error or success notices



I use FSO to set up the success and error files, but the scheduled job in SQL2005 which calls the SSIS package returns the following error:

"Retrieving the file name for a component failed with error code 0x0015F74C"



I can successullly run this (vbscript) in both the SSIS package via the BI Development Studio and in MS Access (exactly the same code in both) - but not as a SSIS package called in a scheduled job in SQL2005.



I am at an impasse with this ... any and ALL assistance would be GREATLY appreciated.



TIA,



Bob

View 1 Replies View Related

Referencing One Item's Hidden Property In Order To Set Another's Hidden Property

Feb 15, 2007

Hello,

I have a group I'll call G4.

The header table row for G4 contains 3 textboxes containing the sums of the contents within G4. The header table row for G4 is visible while it's contents, including the G4 footer table row, is kept invisible until the report user drills down into the group.

When the report user drills down into G4 the footer table row becomes visible and the sums of the contents of the group are displayed for a second time.

At this point I want the sums in the header to be set to invisible when the sums in the footer are made visible by the drilldown.

When I try to reference the hidden property of textbox66 in the G4 footer in order to set the hidden property of header textbox57 in the G4 header I get to this point...

=IIF(reportitems!textbox66.

When it fails to give me an option of choosing the .Hidden property and instead only gives me a .Value.

If I complete the IIF statement manually so that it spells out .....

=IIF(ReportItems!Textbox66.Hidden = False, True, False)

...the report chokes on it.

So my question is, how do I reference the hidden property of one or more textboxes in a group to use as condition checks to set the hidden property of another textbox in that same group?

Thank you for any help you can provide. We are only now beginning to implement reporting services and I have not yet had the chance to research this in greater detail for lack of time.



View 1 Replies View Related

Manipulate Data Being Imported From Another Data Source

Sep 23, 2013

I am trying to manipulate the data being imported from another data source. See below:

I need to make an IF THEN statement: If KeyDate =< 01/01/2013 THEN STATUS = 'Disposed'

Notice I am adding data in the last column as everything is 'Active'

SELECT dbo.UserConfig.Id,
dbo.UserConfig.ServerConfigId, dbo.UserConfig.DisplayName,
dbo.UserConfig.UserName, dbo.UserConfig.MailboxSMTPAddr,
dbo.UserConfig.OverrideSMTPAddr,

[Code] ....

View 3 Replies View Related

ConnectionString Property

Jun 28, 2006

I am having trouble initializing my connection. This is the code:


Dim
DBConnPhone As New
SqlConnection(ConfigurationManager.AppSettings("DBConnPhone"))




        Dim DBConnClient As New
SqlConnection(ConfigurationManager.AppSettings("DBConnClient"))       


        Dim Sqlcomm1 As New SqlCommand


        Dim Sqlcomm2 As New SqlCommand


        DBConnPhone.Open()


       
DBConnClient.Open()

Once I start debugging, it stops and give me the error "The ConnectionString Property was not initialized" Any suggestions?

View 4 Replies View Related

ConnectionString Property Not Set

Feb 14, 2007

 
Hi, After many nights without sleep I'm not seeing this? Can anyone help why I'm getting a ConnectionString Property not set error? thanks!
Dim Sconn As StringDim DBCon As New Data.SqlClient.SqlConnectionSconn = ConfigurationManager.AppSettings("LocalSqlServer")DBCon = New SqlClient.SqlConnection(Sconn)Dim cmdCommand As New Data.SqlClient.SqlCommand
'Dont forget to instantiate a connection object
cmdCommand.Connection = DBConDBCon.Open()

View 18 Replies View Related

How Can I Set Description Property By T-SQL ?

Jun 6, 2007

I would like to create table by T-SQLand need to specify DescriptionBut I can't find any sample to add Description property by T-SQL  Additionally, I also would like modify Description property by T-SQL. What can I do ?????  Please help me ...... 

View 2 Replies View Related







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