471,347 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

SQl Question with VB .NET

Hi

I<m wrting a SQL string in my VB .NET application.

There is a function in my string but it<n not seem working
I have always an syntax error message

this is my quesry
strSQL = "INSERT INTO Tb_client( IDclient, c1CommUOM )" _
& " SELECT Tb_Temp.COMPFILE, " & getAbbrUM( "[TYPE1]" ) & " AS
c1CommUOM FROM Tb_Temp"

Where Type1 is a string in the Table Tb_Temp

Any idea who can I use a function in a SQl Query in a VB .NEt code

Thanks

Jul 21 '05 #1
6 1138

"Hermione" <He******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hi

I<m wrting a SQL string in my VB .NET application.

There is a function in my string but it<n not seem working
I have always an syntax error message

this is my quesry
strSQL = "INSERT INTO Tb_client( IDclient, c1CommUOM )" _
& " SELECT Tb_Temp.COMPFILE, " & getAbbrUM( "[TYPE1]" ) & " AS
c1CommUOM FROM Tb_Temp"

Where Type1 is a string in the Table Tb_Temp

Any idea who can I use a function in a SQl Query in a VB .NEt code

Thanks


What do you want your function to do? Do you want to calculate something
from a column called TYPE1?
What database do you use?

/Fredrik
Jul 21 '05 #2
Hi Fredrik
Thank for your answer

YEs acctually I want to calculate some value regardingthe Type1, and I
already programed the function getAbbrUM.

If you have any idea it<ll be great
"Fredrik Wahlgren" wrote:

"Hermione" <He******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hi

I<m wrting a SQL string in my VB .NET application.

There is a function in my string but it<n not seem working
I have always an syntax error message

this is my quesry
strSQL = "INSERT INTO Tb_client( IDclient, c1CommUOM )" _
& " SELECT Tb_Temp.COMPFILE, " & getAbbrUM( "[TYPE1]" ) & " AS
c1CommUOM FROM Tb_Temp"

Where Type1 is a string in the Table Tb_Temp

Any idea who can I use a function in a SQl Query in a VB .NEt code

Thanks


What do you want your function to do? Do you want to calculate something
from a column called TYPE1?
What database do you use?

/Fredrik

Jul 21 '05 #3

"Hermione" <He******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi Fredrik
Thank for your answer

YEs acctually I want to calculate some value regardingthe Type1, and I
already programed the function getAbbrUM.

If you have any idea it<ll be great

I cab think of 3 ways, I'm not sure about the last one

1) If you use something like Oracle or SQL Server, you need to create a
stored procedure where you define getAbbrUM.

2) Get the values from the mentioned column and loop over them, calling
getAbbrUM on each row

3) Maybe ADO.NET has some kind of built-in functionality that makes this
easier than looping. I think you should ask the ...public.framework.adonet
newsgroup.

/Fredrik
Jul 21 '05 #4
Hello Hermione,

your query cannot call the method GetAbbrUM. You need to create the SQL
statement, send it to SQL Server or whatever database you are using, get
back the results (which will come back as one or more rows), then loop
through the results. In each result, you can extract the field and perform
the calculation.

All you are doing, in the statement below, is passing in the string
"[TYPE1]" to your function... which is probably not what you want.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Hermione" <He******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hi

I<m wrting a SQL string in my VB .NET application.

There is a function in my string but it<n not seem working
I have always an syntax error message

this is my quesry
strSQL = "INSERT INTO Tb_client( IDclient, c1CommUOM )" _
& " SELECT Tb_Temp.COMPFILE, " & getAbbrUM( "[TYPE1]" ) & " AS
c1CommUOM FROM Tb_Temp"

Where Type1 is a string in the Table Tb_Temp

Any idea who can I use a function in a SQl Query in a VB .NEt code

Thanks

Jul 21 '05 #5
thanks Nick

"Nick Malik [Microsoft]" wrote:
Hello Hermione,

your query cannot call the method GetAbbrUM. You need to create the SQL
statement, send it to SQL Server or whatever database you are using, get
back the results (which will come back as one or more rows), then loop
through the results. In each result, you can extract the field and perform
the calculation.

All you are doing, in the statement below, is passing in the string
"[TYPE1]" to your function... which is probably not what you want.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Hermione" <He******@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
Hi

I<m wrting a SQL string in my VB .NET application.

There is a function in my string but it<n not seem working
I have always an syntax error message

this is my quesry
strSQL = "INSERT INTO Tb_client( IDclient, c1CommUOM )" _
& " SELECT Tb_Temp.COMPFILE, " & getAbbrUM( "[TYPE1]" ) & " AS
c1CommUOM FROM Tb_Temp"

Where Type1 is a string in the Table Tb_Temp

Any idea who can I use a function in a SQl Query in a VB .NEt code

Thanks


Jul 21 '05 #6
thanks Fredrik

"Fredrik Wahlgren" wrote:

"Hermione" <He******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi Fredrik
Thank for your answer

YEs acctually I want to calculate some value regardingthe Type1, and I
already programed the function getAbbrUM.

If you have any idea it<ll be great

I cab think of 3 ways, I'm not sure about the last one

1) If you use something like Oracle or SQL Server, you need to create a
stored procedure where you define getAbbrUM.

2) Get the values from the mentioned column and loop over them, calling
getAbbrUM on each row

3) Maybe ADO.NET has some kind of built-in functionality that makes this
easier than looping. I think you should ask the ...public.framework.adonet
newsgroup.

/Fredrik

Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Madhusudan Singh | last post: by
reply views Thread by Alexander Skwar | last post: by
7 posts views Thread by Darren Gamble | last post: by
7 posts views Thread by kecebong | last post: by
reply views Thread by Slavik | last post: by
3 posts views Thread by Garrett Albright | last post: by
reply views Thread by LRW | last post: by
9 posts views Thread by Penn Markham | last post: by
3 posts views Thread by Ron King | last post: by
13 posts views Thread by Gary Quiring | last post: by
reply views Thread by Ronak mishra | last post: by

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.