Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / June 2005

Tip: Looking for answers? Try searching our database.

please I need help with basic ado.net save, basic syntax needed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Newbee Adam - 27 Jun 2005 16:05 GMT
I am having some problems with getting squgglie lines under stringbuilder and
ConfigurationSettings

what am I doing wrong, is this even close to working? help.
------------------------------------------------------------------------------------
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic

Public Class Locations
   Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

 
   Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click

       Dim mySQLConnection As New
SqlConnection(ConfigurationSettings.AppSettings("DSN"))
       Dim strSQLCommand As New StringBuilder, mySQLCommand As SqlCommand
       strSQLCommand = New StringBuilder
       With strSQLCommand
           .Append("INSERT INTO Locations (Loc_Name, Address, ContactName,
Phone) ")
           .Append("VALUES ('" & txtName.Text & "', '" & txtAddress.Text &
"', '" & txtContactName.Text & "', '" & txtPhone.Text & "');")
       End With
       mySQLConnection.Open()
       mySQLCommand = New SqlCommand(strSQLCommand.ToString, mySQLConnection)
       mySQLCommand.ExecuteNonQuery()
       mySQLConnection.Close()

   End Sub
End Class
Signature

thanks!!! Adam S

Jay Pondy - 27 Jun 2005 17:45 GMT
At the top of your source file:

Imports System.Text
Imports System.Configuration.ConfigurationSettings

>I am having some problems with getting squgglie lines under stringbuilder and
>ConfigurationSettings
[quoted text clipped - 32 lines]
>    End Sub
>End Class
Newbee Adam - 27 Jun 2005 18:39 GMT
thanks!!!
is this the basics I need to do a save, that is al i m trying to do is learn
how to do 1 succesful ado.net save
Signature

Adam S

> At the top of your source file:
>
[quoted text clipped - 37 lines]
> >    End Sub
> >End Class
Newbee Adam - 27 Jun 2005 18:46 GMT
i get error , connection string has not been initialized? what is wrong. I am
sure the answer is simple since I am a newbie!!!!
also, this code i just put on a form , do I need to drag the table on form
and make data set and sql adapter and all that, r should this code work
alone? do I have to bind the text boxes in  properties window. be kind, I am
new
Signature

Adam S

> thanks!!!
> is this the basics I need to do a save, that is al i m trying to do is learn
[quoted text clipped - 41 lines]
> > >    End Sub
> > >End Class
Jay Pondy - 27 Jun 2005 20:55 GMT
You are getting your connection string from AppSettings("DSN") .

Do you have an application configuration file in your project?

If you do - what is the value of the key "DSN" that you are calling
for?

If you don't - check out the System.Configuration stuff in the Docs.

The code you have will work - you do not need to drag a table or
anything else on the form.

>i get error , connection string has not been initialized? what is wrong. I am
>sure the answer is simple since I am a newbie!!!!
>also, this code i just put on a form , do I need to drag the table on form
>and make data set and sql adapter and all that, r should this code work
>alone? do I have to bind the text boxes in  properties window. be kind, I am
>new
Newbee Adam - 28 Jun 2005 07:09 GMT
I am not sure about the application config file. how would I now, what would
it be called. is there easir way to make connection string. it is simply sql
server db on local machine
Signature

Adam S

> You are getting your connection string from AppSettings("DSN") .
>
[quoted text clipped - 14 lines]
> >alone? do I have to bind the text boxes in  properties window. be kind, I am
> >new

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.