Anyone do anything in .NET 2005?
Got a snippet of code that is supposed to save to a database. It doesn't. I'll be damned if I can figure it out. Written in VB.
'save to the database
conn = New SqlConnection
conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\cyberhack.mdf;Integrated Security=True;User Instance=True"
Dim sCmdText As String = "INSERT INTO Game ([GameName], [GameDate], [GameTime]) VALUES (@GameName, @Date, @Time)"
Dim cmd As New SqlCommand(sCmdText, conn)
Dim iRow As Integer
cmd.Parameters.Add("@GameName", SqlDbType.VarChar, 50)
cmd.Parameters.Add("@Date", SqlDbType.DateTime)
cmd.Parameters.Add("@Time", SqlDbType.DateTime)
cmd.Parameters("@GameName").Value = txtName.Text
cmd.Parameters("@Date").Value = "01/01/2068"
cmd.Parameters("@Time").Value = "12:00"
MsgBox(conn.ConnectionString)
'cmd.CommandText = "cyberhack.dbo.GameInsert @GameName, @Date, @Time"
cmd.CommandType = CommandType.Text
Try
cmd.Connection = conn
conn.Open()
cmd.Prepare()
iRow = cmd.ExecuteNonQuery
MsgBox(iRow)
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
iRow has a value of 1, which means the call returned 1 row like it should. It does not throw any exceptions.