473,804 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:myconn %>"
SelectCommand=" SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>

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 2377
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.po wrote in message
news:ej******** ******@TK2MSFTN GP05.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:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:myconn %>"
SelectCommand=" SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>

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.ne tschreef in bericht
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.po wrote in message
news:ej******** ******@TK2MSFTN GP05.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:SqlDataSo urce ID="SqlDataSour ce1" runat="server"
ConnectionStri ng="<%$ ConnectionStrin gs:myconn %>"
SelectCommand= "SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>

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.po wrote in message
news:ub******** ******@TK2MSFTN GP03.phx.gbl...
Thanks for replying, but i get the same error.

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

"Eric" <er*@sdsclem.po wrote in message
news:ej******* *******@TK2MSFT NGP05.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:SqlDataS ource ID="SqlDataSour ce1" runat="server"
ConnectionStr ing="<%$ ConnectionStrin gs:myconn %>"
SelectCommand ="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>

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.ne tschreef in bericht
news:uj******** ********@TK2MSF TNGP03.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.po wrote in message
news:ub******** ******@TK2MSFTN GP03.phx.gbl...
>Thanks for replying, but i get the same error.

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

"Eric" <er*@sdsclem.po wrote in message
news:ej****** ********@TK2MSF TNGP05.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:SqlData Source ID="SqlDataSour ce1" runat="server"
ConnectionSt ring="<%$ ConnectionStrin gs:myconn %>"
SelectComman d="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>

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.po wrote in message
news:ux******** ********@TK2MSF TNGP05.phx.gbl. ..
It works if i do this:
SELECT left(n1,10) as n1 (with the same fieldname in the alias.

"sloan" <sl***@ipass.ne tschreef in bericht
news:uj******** ********@TK2MSF TNGP03.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.po wrote in message
news:ub******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Thanks for replying, but i get the same error.

"sloan" <sl***@ipass.ne tschreef in bericht
news:%2****** **********@TK2M SFTNGP06.phx.gb l...
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]

"Eric" <er*@sdsclem.po wrote in message
news:ej***** *********@TK2MS FTNGP05.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:SqlDat aSource ID="SqlDataSour ce1" runat="server"
ConnectionS tring="<%$ ConnectionStrin gs:myconn %>"
SelectComma nd="SELECT left(field1,10) FROM [mytable]">
</asp:SqlDataSour ce>
>
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
2738
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
2642
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 group" button that makes the the panel inwhich the add_customer control resides VISIBLE=True. On the control, the user can edit the list of groups, or add a new one. After the edit is complete I want to make the panel again VISIBLE=False, as well as...
0
980
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
2429
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 error msg returned is: Cannot insert the employee. With tracing trigger on, I had discovered that the parameter is actually empty. The data entered is not pass into the parameter at all !!! What could be the possible reason?
2
19796
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 <selectParameters> but i don't know which elements are needed and how... This is my aspx file: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb"
4
2153
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 set . These I have cleaned up ok. But I have a few like this one below. The error is Function BindData doesn't return a value on all code paths But I only see one code path. What am I missing?
0
3429
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 accessdatasource. In my code-behind I want to be able to set the selectcommand of the datasource to a specific SQL string based on a user's input to retrieve only certain records.
6
6757
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 as the LEFT location of a control or something like that, instead of the LEFT function. (I want to extract the left portion of a string). Anyway, I knew what I needed was to find out what IMPORTS I was missing. After finding a posting on MSDN that...
14
1623
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 advance class esodbconnection { public DataViewManager fnGetConnectedToDatabase(string dbname, string tablename, string tablename1, string whereclass, string groupbyclass) { ResortApplication.conf configdb = new...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.