473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to use left function in a selectcommand in aspx file?

Hi,

i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable

Now, i tried the same in aspx file: i dragged a sqldatasource control and
changed manually the select commend like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>

But here, i get the error:
"no field or property met with the name field1in the selected source .."(or
something)

Any way to limit the text of field 'field1' to 10 characters?

Thanks
Eric
Oct 22 '08 #1
5 2360
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.powrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
Hi,

i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable

Now, i tried the same in aspx file: i dragged a sqldatasource control and
changed manually the select commend like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>

But here, i get the error:
"no field or property met with the name field1in the selected source
.."(or something)

Any way to limit the text of field 'field1' to 10 characters?

Thanks
Eric

Oct 22 '08 #2
Thanks for replying, but i get the same error.

"sloan" <sl***@ipass.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.powrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
>Hi,

i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable

Now, i tried the same in aspx file: i dragged a sqldatasource control and
changed manually the select commend like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>

But here, i get the error:
"no field or property met with the name field1in the selected source
.."(or something)

Any way to limit the text of field 'field1' to 10 characters?

Thanks
Eric


Oct 22 '08 #3
Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).
"Eric" <er*@sdsclem.powrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
Thanks for replying, but i get the same error.

"sloan" <sl***@ipass.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
>THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.powrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
>>Hi,

i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable

Now, i tried the same in aspx file: i dragged a sqldatasource control
and changed manually the select commend like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>

But here, i get the error:
"no field or property met with the name field1in the selected source
.."(or something)

Any way to limit the text of field 'field1' to 10 characters?

Thanks
Eric



Oct 22 '08 #4
It works if i do this:
SELECT left(n1,10) as n1 (with the same fieldname in the alias.

"sloan" <sl***@ipass.netschreef in bericht
news:uj****************@TK2MSFTNGP03.phx.gbl...
Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).
"Eric" <er*@sdsclem.powrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
>Thanks for replying, but i get the same error.

"sloan" <sl***@ipass.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.powrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
Hi,

i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable

Now, i tried the same in aspx file: i dragged a sqldatasource control
and changed manually the select commend like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>

But here, i get the error:
"no field or property met with the name field1in the selected source
.."(or something)

Any way to limit the text of field 'field1' to 10 characters?

Thanks
Eric



Oct 22 '08 #5
Oh, ok.

I was close....

Glad you figured it out.
"Eric" <er*@sdsclem.powrote in message
news:ux****************@TK2MSFTNGP05.phx.gbl...
It works if i do this:
SELECT left(n1,10) as n1 (with the same fieldname in the alias.

"sloan" <sl***@ipass.netschreef in bericht
news:uj****************@TK2MSFTNGP03.phx.gbl...
>Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).
"Eric" <er*@sdsclem.powrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
>>Thanks for replying, but i get the same error.

"sloan" <sl***@ipass.netschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.powrote in message
news:ej**************@TK2MSFTNGP05.phx.gbl...
Hi,
>
i tested this sql command directly with sql server and it works:
select left(field1,10) from mytable
>
Now, i tried the same in aspx file: i dragged a sqldatasource control
and changed manually the select commend like this:
>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myconn %>"
SelectCommand="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSource>
>
But here, i get the error:
"no field or property met with the name field1in the selected source
.."(or something)
>
Any way to limit the text of field 'field1' to 10 characters?
>
Thanks
Eric
>




Oct 22 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: | last post by:
From ASP I run a query using MIN(some_field/parameter) Now I need to pass this parameter to the query from ASP code How do I do that? Syntax like MIN( / ) does not work
1
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add...
0
by: prontoo | last post by:
How kan I change the selectcommand on sqldatasource from standard (not html) button on event click in aspx.vb file Thank you!
3
by: CWWong | last post by:
I am using DetailsView using ObjectDataSource with DataSourceTypeName assigned to the specific class. SelectMethod, UpdateMethod and DeleteMethod is working successfully, except InsertMethod. The...
2
by: phil | last post by:
Hi, I want to put a recordset in a gridview but i don't know how to pass the value of the variable in the 'where' statement. The value of the variable is set in the code-behind. i added a tag...
4
by: a | last post by:
I have been cleaning up somebody else's code in Vs2005 .net 2.0 There wer lots of these code pat errors because of unitialized variables in functions with Conditionals - that may or may not be...
0
by: mlfblom | last post by:
Hi, I know I am not the only one struggling with the following, but so far I have not seen a solution. Problem: I have an asp.net 2.0 web page with a gridview which is bound to an...
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have two questions with regards to the LEFT function. I ran into a problem with the LEFT function today. I knew it was a valid Function, but when I tried to use it, it was getting interpreted...
14
by: gggram2000 | last post by:
Can anyone tell me if this class will function properly...I'm using MS Visual Studio 2005, using C#. I notice there's no C# forum but hopefully u guys are familiar with the language...thanks in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.