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

E

Eric

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
 
E

Eric

Thanks for replying, but i get the same error.

sloan said:
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]



Eric said:
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
 
S

sloan

Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).


Eric said:
Thanks for replying, but i get the same error.

sloan said:
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]



Eric said:
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
 
E

Eric

It works if i do this:
SELECT left(n1,10) as n1 (with the same fieldname in the alias.

sloan said:
Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).


Eric said:
Thanks for replying, but i get the same error.

sloan said:
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]



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
 
S

sloan

Oh, ok.

I was close....

Glad you figured it out.


Eric said:
It works if i do this:
SELECT left(n1,10) as n1 (with the same fieldname in the alias.

sloan said:
Use storedprocedure, or get the data, then .. fix it. (Which is what the
presentation layer is supposed to do anyways).


Eric said:
Thanks for replying, but i get the same error.

"sloan" <[email protected]> schreef in bericht
THrow in an alias I think
SELECT left(field1,10) as MyAlias1 FROM [mytable]



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top