473,327 Members | 1,952 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,327 software developers and data experts.

VB.NET > SQL Database

Hi all,
Longtime listener, first time caller...anyways, I'm just starting out
(literally...I've done the obligatory "Hello, World" and messed around a
little more). What I want to do is create an app that will accept 2
character strings, and when 'OK' is clicked, have it dump one string into
one field in a SQL table (SQL server is the same machine as I'll be using
and writing the program with), and dump the other string into a different
field in the same table. The database has 3 tables in it, and all are empty
awaiting data. I'm fairly competent with SQL statements, but as I said, I'm
VERY new to Visual Basic, and especially the .NET framework. What I'm stuck
on is the code to make the text boxes dump the data into the database. I
don't even know how to tell it to establish a connection to the SQL Server.
(This program won't ever be run on another computer, it's just for my own
purposes, so I don't need to have a selection for servers or databases.) I'm
hoping someone would be so kind as to get me started here or point me to a
place on the web or book that deals with getting the data into the database.
Basically, what I'm doing is writing a data entry program. At this point, I
don't even need to manipulate the data with the program, just get it into
the database. Any help is appreciated! Thank you!

KB
Nov 19 '05 #1
1 11362
Ken,

1. Create a connection and sets its ConnectionString property
Dim conn as New SQLConnection
conn.ConnectionString = <the connection string to your database>

2. Create a command to insert the data
I'll assume your using a stored procedure with 2 parameters named @Text1 and
@Text2 and the datatypes are VarChar(100)
Dim cmd as New SqlCommand
With cmd
.Connection = conn
.CommandType = CommandType.StoredProcedure
.CommandText = <name of your stored procedure>
With .Parameters
.Add("@Text1", SqlDbType.VarChar, 100).Value = TextBox1.Text
.Add("@Text2", SqlDbType.VarChar, 100).Value = TextBox2.Text
End With
End With

3. Open the connection and execute the command
Try
conn.Open
cmd.ExecuteNonQuery
Catch ex as Exception
..........
Finally
conn.Close
End Try

Read the help files on SqlConnection and SqlCommand

Stephen

"Ken Briscoe" <no****@nospam.invalid> wrote in message
news:%dhYa.55583$cF.19877@rwcrnsc53...
Hi all,
Longtime listener, first time caller...anyways, I'm just starting out
(literally...I've done the obligatory "Hello, World" and messed around a
little more). What I want to do is create an app that will accept 2
character strings, and when 'OK' is clicked, have it dump one string into
one field in a SQL table (SQL server is the same machine as I'll be using
and writing the program with), and dump the other string into a different
field in the same table. The database has 3 tables in it, and all are empty awaiting data. I'm fairly competent with SQL statements, but as I said, I'm VERY new to Visual Basic, and especially the .NET framework. What I'm stuck on is the code to make the text boxes dump the data into the database. I
don't even know how to tell it to establish a connection to the SQL Server. (This program won't ever be run on another computer, it's just for my own
purposes, so I don't need to have a selection for servers or databases.) I'm hoping someone would be so kind as to get me started here or point me to a
place on the web or book that deals with getting the data into the database. Basically, what I'm doing is writing a data entry program. At this point, I don't even need to manipulate the data with the program, just get it into
the database. Any help is appreciated! Thank you!

KB

Nov 19 '05 #2

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

Similar topics

1
by: vishal | last post by:
i am making an application. the user can give description and that description is stored in database and then the description is shown on html page. suppose the user has written "<b>hello</b>"...
2
by: Rene Pijlman | last post by:
I can't seem to find any way to specify the character encoding with the DB API implementation of PyPgSQL. There is no mention of encoding and Unicode in the DB API v2.0 spec and the PyPgSQL README....
5
by: john | last post by:
Hi I am devlopeing a data centric intranetsite with data in mysql database I would like your opinion on this architecture Data will be fetched from database by python & converted into xml The...
4
by: jason | last post by:
I would appreciate some help on how to convert a database table into an html file via FSO and whether more seasoned asp programmers recommned this route. The main reason I am attempting to do this...
2
by: jason | last post by:
Is there a specific path I can follow to upsize my access 2000 database which has: 20 tables - mixture of primary and foreign tables 20 queries (action, select etc) Built on top of this...
2
by: NOSPAM | last post by:
Hello, I am hoping you can help me with the following problem; I need to process the following steps every couple of hours in order to keep our Sql 2000 database a small as possible (the...
0
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
2
by: mit | last post by:
Hello friends , Here i have problem. I want to make the online job web site .But i donts know much about asp.net .so if any body provide me suggestion to how to create online resume database...
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.