creating a class

parkerburnt

New Member
Now that I have worked out how to parse and output an SQL command, I need to apply this to a class, so that I can call it within any application. However, my knowledge of OO programming is limited.<BR><BR>Can someone please advise me on how I put the following code (comments define start and end of class code) into a class and call it? I not sure about passing SQL command to the class.<BR><BR>----<BR><BR>con = New SqlConnection "Server=sqlserver;UID=me;PWD=pwd;Database=db")<BR>SQL = New SqlCommand("SELECT * FROM table WHERE id = @id", con)<BR>SQL.Parameters.Add("@id", 3)<BR>con.Open()<BR>datareader = SQL.ExecuteReader()<BR><BR><BR>'// code to put in class -------------------<BR><BR>sqlcommand = SQL.commandtext.tostring<BR>for param=0 to SQL.Parameters.Count<BR>sqlcommand = replace(sqlcommand, SQL.Parameters(param).tostring, SQL.Parameters(param).value.tostring)<BR>param + = 1<BR>next<BR>response.write("<BR>sqlcommand: " & sqlcommand & "<BR>")<BR><BR>'// end of code to put in class ------------<BR><BR><BR>Cheers<BR><BR>Dave <BR>Download the iBuySpy portal and study it.. It will give you a general idea of how to create classes and compile them to the bin directory so you can use them in your program. It also makes use of static/shared methods. Which is probably what you want here... However I think it would defenitly benifit you to pick up a book on vb.net or c# and study oop. <BR><BR>http://www.asp.net/ibuyspy/downloads.aspx?tabindex=3
 
Back
Top