473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

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("D SN"))
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
--
thanks!!! Adam S
Jul 22 '05 #1
5 1363

At the top of your source file:

Imports System.Text
Imports System.Configuration.ConfigurationSettings

On Mon, 27 Jun 2005 08:05:06 -0700, "Newbee Adam"
<Ne********@discussions.microsoft.com> wrote:
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


Jul 22 '05 #2
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
--
Adam S
"Jay Pondy" wrote:

At the top of your source file:

Imports System.Text
Imports System.Configuration.ConfigurationSettings

On Mon, 27 Jun 2005 08:05:06 -0700, "Newbee Adam"
<Ne********@discussions.microsoft.com> wrote:
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


Jul 22 '05 #3
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
--
Adam S
"Newbee Adam" wrote:
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
--
Adam S
"Jay Pondy" wrote:

At the top of your source file:

Imports System.Text
Imports System.Configuration.ConfigurationSettings

On Mon, 27 Jun 2005 08:05:06 -0700, "Newbee Adam"
<Ne********@discussions.microsoft.com> wrote:
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


Jul 22 '05 #4
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.
On Mon, 27 Jun 2005 10:46:08 -0700, "Newbee Adam"
<Ne********@discussions.microsoft.com> wrote:
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


Jul 22 '05 #5
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
--
Adam S
"Jay Pondy" wrote:
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.
On Mon, 27 Jun 2005 10:46:08 -0700, "Newbee Adam"
<Ne********@discussions.microsoft.com> wrote:
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


Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Dimension7 | last post by:
All, I am comparing to functions to see which is "better". In better, I mean more efficient, optimize, faster, etc. I have read other posts from other boards, but I'm not really sure of the...
21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
15
by: Buck Rogers | last post by:
Hi guys! Task 1: Write a program which presents a menu with 5 options. The 5th option quits the program. Each option should execute a system command using system(). Below is my humble...
11
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army...
59
by: Alan Silver | last post by:
Hello, This is NOT a troll, it's a genuine question. Please read right through to see why. I have been using Vusual Basic and Classic ASP for some years, and have now started looking at...
5
by: Newbee Adam | last post by:
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....
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
118
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.