LostProgrammer
Well-known member
- Joined
- Jan 17, 2003
- Messages
- 123
My first time to forum and I have a question for everyone. This is probly a easy question, but I am completely lost.
I made this stored procedure in SQL
CREATE PROCEDURE procGetSystemDate
AS
DECLARE @SQL nvarchar(100)
Select @SQL = "SELECT GetDate() AS SysDate"
EXEC sp_executeSQL @SQL
GO
Very simple, when executed it returns the current date/time from the server. I would like to beable to call this procedure in VB .net and store the time in my own vb.net datetime variable. Im clueless on how to do this. Here is my latest attempt at getting the variable.
So anyways I dont think I am even close to getting this right, I have never used procedures before. Anyone have any ideas?
LostProgrammer
I made this stored procedure in SQL
CREATE PROCEDURE procGetSystemDate
AS
DECLARE @SQL nvarchar(100)
Select @SQL = "SELECT GetDate() AS SysDate"
EXEC sp_executeSQL @SQL
GO
Very simple, when executed it returns the current date/time from the server. I would like to beable to call this procedure in VB .net and store the time in my own vb.net datetime variable. Im clueless on how to do this. Here is my latest attempt at getting the variable.
Code:
Dim curTime As DateTime
Dim cmdSql As New SqlClient.SqlCommand("procGetGystemDate")
Dim conSql As New SqlClient.SqlConnection()
Dim rdrSql As SqlClient.SqlDataReader
conSql.ConnectionString = _
"Integrated Security=True;Data Source=10.10.1.47;Initial Catalog=TimeLog;"
cmdSql.Connection = conSql
conSql.Open()
rdrSql = cmdSql.ExecuteReader(CommandBehavior.CloseConnection)
rdrSql.Read()
curTime = rdrSql.GetDateTime(0)
lbl.Text = curTime
rdrSql.Close()
So anyways I dont think I am even close to getting this right, I have never used procedures before. Anyone have any ideas?
LostProgrammer
Last edited by a moderator: