I keep getting a Connection String property is not initialized error
when I run my code and I can't figure out why. I am using Visual
Basic 2005 and this is a web application.
Here is my code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim oConn As New
System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings("CMSConnectionString"))
Dim cmd As New System.Data.SqlClient.SqlCommand()
cmd.Connection = oConn
oConn.Open()
cmd.CommandText = "INSERT into
Timecard(INEENO,INDTWE,INWKNO,INDYWK, INJBNO, INGLAN, INJCDI, INRGHR,
INOVHR, INOTHR, INOTTY) values('" & EmplID1.Text & "','" &
DatePicker1.DateValue & "','" & DD_DayofWeek.Text & "','" &
DD_jobno.Text & "','" & GLAcct.Text & "','" & DD_CostCode.Text & "','"
& RegHrs.Text & "','" & OTHrs.Text & "','" & OthHrs.Text & "','" &
DD_OthHourType.Text & "')"
cmd.ExecuteNonQuery()
oConn.Close()
End Sub
I checked my connection string code in my web.config file and it looks
fine. Any ideas on what I'm doing wrong. I'm thinking its my syntax
in my code or something. This is my first I've attempted this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/DotNetDevelopment
You may subscribe to group Feeds using a RSS Feed Reader to stay upto date
using following url
<a href="http://feeds.feedburner.com/DotNetDevelopment">
http://feeds.feedburner.com/DotNetDevelopment</a>
-~----------~----~----~----~------~----~------~--~---