Can someone tell my why my functions are returning "nothing"?
In the SQLStatement Sub, ColumnNames & FromClause & WhereClause &
OrderClause all come up as "nothing". I can't figure out why my
functions are not working. When I step through the code, the parameter
is passed, but as soon as it executes the return line, the strings are
set to "nothing.
Any ideas?
Thanks,
Aaron
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SQLStatement()
End Sub
Function SQLConnect(ByVal ServerName As String, ByVal UserName As
String, ByVal Password As String, ByVal Database As String) As
SqlClient.SqlConnection
Dim sqlcon As New SqlClient.SqlConnection() ' Dim new SQL
connection object
sqlcon.ConnectionString = "Server=" & ServerName & ";User ID=" &
UserName & ";password=" & Password & ";Database=" & Database ' Connection
string
sqlcon.Open() ' Open a connection to the DB
Return sqlcon
End Function
Function SQLColumnNames(ByVal Columns As String) As String
Dim ColumnNames As String
ColumnNames = Columns
Return ColumnNames
End Function
Function SQLFromClause(ByVal TableName As String) As String
Dim FromClause As String
FromClause = " From " & TableName
Return FromClause
End Function
Function SQLWhereClause(ByVal Criteria As String) As String
Dim WhereClause As String
WhereClause = " Where " & Criteria
Return WhereClause
End Function
Function SQLOrderClause(ByVal OrderColumn As String) As String
Dim OrderClause As String
OrderClause = " Order by " & OrderColumn
Return OrderClause
End Function
Sub SQLStatement()
Dim SqlCon As SqlClient.SqlConnection
Dim DA As SqlClient.SqlDataAdapter
Dim SqlCmd As SqlClient.SqlCommand
Dim SQLSelectStatement As String
Dim ColumnNames As String
Dim FromClause As String
Dim WhereClause As String
Dim OrderClause As String
Dim DS As DataSet
SqlCon = SQLConnect("Boca2", "USER", "PASSWORD", "pursuittest")
SQLColumnNames("Person_ID")
SQLFromClause("Person")
SQLWhereClause("company_ID > 3623")
SQLOrderClause("company_ID")
SQLSelectStatement = "Select" & ColumnNames & FromClause &
WhereClause & OrderClause
SqlCmd.CommandText = SQLSelectStatement
DA.SelectCommand = SqlCmd
DA.Fill(DS, "test")
SqlCon.Close()
End Sub
End Class 3 1038
It has nothing to do with the syntax of your functions, they're fine.
You are calling those functions - but you are not assigning the result to
the variables you've declared. So they do their job, return the result - but
that result is discarded, since there is no assignment happening. The
compiler can't know which variable you mean to assign to which function
call.
"Aaron" <a_******@hotmail.com> wrote in message
news:Xn********************************@207.46.248 .16... Can someone tell my why my functions are returning "nothing"?
In the SQLStatement Sub, ColumnNames & FromClause & WhereClause & OrderClause all come up as "nothing". I can't figure out why my functions are not working. When I step through the code, the parameter is passed, but as soon as it executes the return line, the strings are set to "nothing.
Any ideas?
Thanks, Aaron
Public Class WebForm2 Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SQLStatement() End Sub
Function SQLConnect(ByVal ServerName As String, ByVal UserName As String, ByVal Password As String, ByVal Database As String) As SqlClient.SqlConnection Dim sqlcon As New SqlClient.SqlConnection() ' Dim new SQL connection object sqlcon.ConnectionString = "Server=" & ServerName & ";User ID=" & UserName & ";password=" & Password & ";Database=" & Database ' Connection string sqlcon.Open() ' Open a connection to the DB Return sqlcon End Function
Function SQLColumnNames(ByVal Columns As String) As String Dim ColumnNames As String ColumnNames = Columns Return ColumnNames End Function
Function SQLFromClause(ByVal TableName As String) As String Dim FromClause As String FromClause = " From " & TableName Return FromClause End Function
Function SQLWhereClause(ByVal Criteria As String) As String Dim WhereClause As String WhereClause = " Where " & Criteria Return WhereClause End Function
Function SQLOrderClause(ByVal OrderColumn As String) As String Dim OrderClause As String OrderClause = " Order by " & OrderColumn Return OrderClause End Function
Sub SQLStatement() Dim SqlCon As SqlClient.SqlConnection Dim DA As SqlClient.SqlDataAdapter Dim SqlCmd As SqlClient.SqlCommand Dim SQLSelectStatement As String Dim ColumnNames As String Dim FromClause As String Dim WhereClause As String Dim OrderClause As String Dim DS As DataSet SqlCon = SQLConnect("Boca2", "USER", "PASSWORD", "pursuittest") SQLColumnNames("Person_ID") SQLFromClause("Person") SQLWhereClause("company_ID > 3623") SQLOrderClause("company_ID") SQLSelectStatement = "Select" & ColumnNames & FromClause & WhereClause & OrderClause SqlCmd.CommandText = SQLSelectStatement DA.SelectCommand = SqlCmd DA.Fill(DS, "test") SqlCon.Close() End Sub End Class
instaid of SQLColumnNames("Person_ID") SQLFromClause("Person") SQLWhereClause("company_ID > 3623") SQLOrderClause("company_ID") SQLSelectStatement = "Select" & ColumnNames & FromClause & WhereClause & OrderClause
try this
SQLSelectStatement = "Select" & SQLColumnNames("Person_ID") &
SQLFromClause("Person") & _
SQLWhereClause("company_ID > 3623") & SQLOrderClause("company_ID")
But i don't have a qlue why you would want to do this using functions? I
think you would get a better functionallity using vars. If you are working
on web pages i would suggest having a look at the session vars (to keep
values for a user as he is posting back pages)
hope it helps
eric
"Aaron" <a_******@hotmail.com> wrote in message
news:Xn********************************@207.46.248 .16... Can someone tell my why my functions are returning "nothing"?
In the SQLStatement Sub, ColumnNames & FromClause & WhereClause & OrderClause all come up as "nothing". I can't figure out why my functions are not working. When I step through the code, the parameter is passed, but as soon as it executes the return line, the strings are set to "nothing.
Any ideas?
Thanks, Aaron
Public Class WebForm2 Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SQLStatement() End Sub
Function SQLConnect(ByVal ServerName As String, ByVal UserName As String, ByVal Password As String, ByVal Database As String) As SqlClient.SqlConnection Dim sqlcon As New SqlClient.SqlConnection() ' Dim new SQL connection object sqlcon.ConnectionString = "Server=" & ServerName & ";User ID=" & UserName & ";password=" & Password & ";Database=" & Database ' Connection string sqlcon.Open() ' Open a connection to the DB Return sqlcon End Function
Function SQLColumnNames(ByVal Columns As String) As String Dim ColumnNames As String ColumnNames = Columns Return ColumnNames End Function
Function SQLFromClause(ByVal TableName As String) As String Dim FromClause As String FromClause = " From " & TableName Return FromClause End Function
Function SQLWhereClause(ByVal Criteria As String) As String Dim WhereClause As String WhereClause = " Where " & Criteria Return WhereClause End Function
Function SQLOrderClause(ByVal OrderColumn As String) As String Dim OrderClause As String OrderClause = " Order by " & OrderColumn Return OrderClause End Function
Sub SQLStatement() Dim SqlCon As SqlClient.SqlConnection Dim DA As SqlClient.SqlDataAdapter Dim SqlCmd As SqlClient.SqlCommand Dim SQLSelectStatement As String Dim ColumnNames As String Dim FromClause As String Dim WhereClause As String Dim OrderClause As String Dim DS As DataSet SqlCon = SQLConnect("Boca2", "USER", "PASSWORD", "pursuittest") SQLColumnNames("Person_ID") SQLFromClause("Person") SQLWhereClause("company_ID > 3623") SQLOrderClause("company_ID") SQLSelectStatement = "Select" & ColumnNames & FromClause & WhereClause & OrderClause SqlCmd.CommandText = SQLSelectStatement DA.SelectCommand = SqlCmd DA.Fill(DS, "test") SqlCon.Close() End Sub End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Julien - Marseille |
last post by:
Hello,
I need help for php syntax when i call Mysql database
I have wrote that and my sql connection is working
I just have a problem with this command line :
$query = "SELECT * FROM...
|
by: JN |
last post by:
Hello. Sorry about the length of this post. I am trying to implement a hash
table for my chess program, and decided to try using the VC++ . NET
(Dinkumware) version of hash_map.
The role of the...
|
by: iksrazal |
last post by:
Hi all,
I've been struggling to make this command work from Java:
/usr/bin/mysql c4 --user=root --password=mypass -e "source
/home/crissilva/c4.sql"
Works fine as shown when run from the...
|
by: stu_gots |
last post by:
I have been losing sleep over this puzzle, and I'm convinced my train
of thought is heading in the wrong direction. It is difficult to
explain my circumstances, so I will present an identical...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: ATS |
last post by:
I'm trying to set up a slide show on a web page using Javascript. Here is
the code I have so far:
<script language="javascript">
alert("**in test area 1");
slides = new Array();
slides =...
|
by: Cap'n Ahab |
last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new
to me (although I looked at Java a few years ago). Anyway, I thought I
would write a small class to begin with, with a...
|
by: MPA |
last post by:
Hi,
We are a small company with experience in client-server apps with
PowerBuilder and most major databases. We have no internet experience. We
are now looking into slimming our main application,...
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: mshroom12 |
last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do.
Election Day It's almost election day and the election officials need a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |