[Message Deleted]
-
campbells wrote:
Dim dbb As Database
There is no type called "Database", unless you define it somewhere. The error means that you haven't defined it anywhere.
campbells wrote:
'Check to see if sp exists and delete it if it does. strSQL = "if exists " strSQL = strSQL & "SELECT dep.[name],dep.deptcode,dep.deptdesc,dep.depttotal, (dep.DeptTotal / " strSQL = strSQL & "(SELECT SUM(ti.totalsales)" strSQL = strSQL & "FROM tot_item ti)) * 100 AS PercentOfSales" strSQL = strSQL & "FROM (SELECT v.[name],d.deptcode,d.deptdesc, SUM(ti.totalsales) AS DeptTotal" strSQL = strSQL & "FROM item i ,vendor v,tot_item ti INNER JOIN dept d ON" strSQL = strSQL & "(ti.deptcode=d.deptcode) where ti.itemcode=i.itemcode and v.vendorid=i.vendorid and v.name<=@vvfrom" strSQL = strSQL & "group by v.[name],d.deptcode,d.deptdesc) AS dep" strSQL = strSQL & "ORDER BY dep.[name] ASC" strSQL = strSQL & "DROP PROCEDURE dbo.sp_ReturnParams"
You do know that you can store this stuff in the database as a Stored Procedure, then just call the procedure from your code, right?
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Dim oConnection As SqlConnection Dim oCommand As SqlCommand
oCommand.Connection = oConnection
' Name of stored procedure you want to call...
oCommand.CommandText = "GetSystemParameter"
oCommand.CommandType = CommandType.StoredProcedure
Dim sqlParam As New SqlParameter("@ParmName", SqlDbType.NVarChar, 25)
sqlParam.Direction = ParameterDirection.Input
sqlParam.Value = sParamName
oCommand.Parameters.Add(sqlParam)
oConnection.Open()
oCommand.ExecuteNonQuery()
oConnection.Close()Dave Kreskowiak Microsoft MVP - Visual Basic