Funny !!

As must be obvious in hindsight, use
ConfigurationManager.ConnectionStrings instead of AppSettings. ;-)

On Oct 29, 8:52 pm, Imstac <[EMAIL PROTECTED]> wrote:
> I think maybe I'm using the wrong command since my connection is in
> the connection string section.  Here is my web.config file code:
>
> <connectionStrings>
>   <add name="CMSConnectionString" connectionString="Data
> Source=AUSSQL;Initial Catalog=CMS;User ID=timecard;Password=***"
>    providerName="System.Data.SqlClient" />
>   <add name="CMSConnectionString2" connectionString="Data
> Source=AUSSQL;Initial Catalog=CMS;Persist Security Info=True;User
> ID=crd;Password=**"
>    providerName="System.Data.SqlClient" />
>  </connectionStrings>
>
> On Oct 27, 1:58 pm, CK <[EMAIL PROTECTED]> wrote:
>
>
>
> > what you are doing wrong (but its not causing your error) is to use
> > the appSettings section for your connection string.  there is a
> > connectionStrings section just for that :)
>
> > On 24 Oct, 21:29, Imstac <[EMAIL PROTECTED]> wrote:
>
> > > 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("CMSCo­­­nnectionString"))
> > >         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.- Hide 
> > > quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to