I'm trying to run this Store Procedure in my application. The code runs without problems but my database stays empty.
C# code:
SQLConnection.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + @"|DataDirectory|\Server Info.mdf" + ";Integrated Security=True;Connect Timeout=30;User Instance=True";
SQLConnection.Open();
SqlCommand SQLCommand = new SqlCommand("insertHddInfo",SQLConnection);
SQLCommand.CommandType = CommandType.StoredProcedure;
SQLCommand.Parameters.Add("@dateInsert", SqlDbType.Date);
SQLCommand.Parameters["@dateInsert"].Value = DateTime.Now.ToShortDateString();
SQLCommand.Parameters.AddWithValue("@serverIP", txtComputerIP.Text);
SQLCommand.Parameters.AddWithValue("@serverName", txtComputerIP.Text);
SQLCommand.Parameters.AddWithValue("@hardDriveName",oReturn["Name"].ToString());
SQLCommand.Parameters.AddWithValue("@totalSpace", dblTotalSpace);
SQLCommand.Parameters.AddWithValue("@usedSpace", dblUsedSpace);
SQLCommand.Parameters.AddWithValue("@usedPercentage", dblUsedPercentage);
SQLCommand.Parameters.AddWithValue("@freeSpace", dblFreeSpace);
SQLCommand.Parameters.AddWithValue("@freeSpacePersentage", dblFreePercentage);
SQLCommand.ExecuteNonQuery();
SQLConnection.Close();
SQL Procedure
USE [Server Info]
GO
/****** Object: StoredProcedure [dbo].[insertHddInfo] Script Date: 05/21/2010 19:57:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[insertHddInfo]
-- Add the parameters for the stored procedure here
@dateInsert date,
@serverIP text,
@serverName text,
@hardDriveName text,
@totalSpace decimal,
@usedSpace decimal,
@usedPercentage float,
@freeSpace decimal,
@freeSpacePersentage float
AS
BEGIN
-- Insert statements for procedure here
INSERT INTO dbo.hddInfo (dateInsert,serverIP,ServerName, hardDriveName, totalSpace, usedSpace, usedPercentage, freeSpace, freeSpacePersentage)
VALUES (@dateInsert,@serverIP,@ServerName,@hardDriveName,@totalSpace,@usedSpace,@usedPercentage,@freeSpace,@freeSpacePersentage)
END

New Topic/Question
Reply




MultiQuote




|