Haii...
Im trying to save date and time in database. Right now im trying declared time and date, but have problem in assigning it to a variable, where afterwords im try to use it to insert in the database. This is the code that i use:
After been compiled i get this error messageCode:Dim dt As DateTime = DateTime.Now lblTimeNow.Text = dt.ToLocalTime Dim masa As String masa = dt.ToLocalTime.ToString() Dim DataSource As New SqlConnection("Data Source=ANNAS\SQLEXPRESS; Initial Catalog=DBRMS;Integrated Security=True") Dim command As New SqlCommand("INSERT INTO Customers(Time) VALUES (masa)", DataSource) DataSource.Open() command.ExecuteNonQuery() DataSource.Close()
The name "masa" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Can,anyone help me with this, thank u




Reply With Quote