473,411 Members | 2,154 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,411 software developers and data experts.

simple database addnew record

36
hi Im new to Vb and i need help with vb 2005

i have a form (Form1)
textbox (Textbox1)
Button (Buton1)

and a database [sql server 2005 express] (database1)
table (Table1)
column (Name)

i need to add a name to the database when i click the button 1

i know this is verry simple but im a newby to vb so any help is preciated

plaease help me
Jul 28 '07 #1
5 1661
gayano
36
anybody??
Need help
Jul 28 '07 #2
pureenhanoi
175 100+
hi Im new to Vb and i need help with vb 2005

i have a form (Form1)
textbox (Textbox1)
Button (Buton1)

and a database [sql server 2005 express] (database1)
table (Table1)
column (Name)

i need to add a name to the database when i click the button 1

i know this is verry simple but im a newby to vb so any help is preciated

plaease help me
If you've been ever using database, so what will you do after add a name from textbox into database. Try learning database from begining. Buy some book that teach base-knownledge about database. Work with simple database management first (example: MS-Access) before using coplicated database management like SQL-Server. I can give you the code to do what you want above, but it cant help you longer in your latter application.
Jul 28 '07 #3
gayano
36
If you've been ever using database, so what will you do after add a name from textbox into database. Try learning database from begining. Buy some book that teach base-knownledge about database. Work with simple database management first (example: MS-Access) before using coplicated database management like SQL-Server. I can give you the code to do what you want above, but it cant help you longer in your latter application.
I'm trying to learn but, i need a kick to start on so if you can give me the code
it'll be a good kick for the start
Jul 28 '07 #4
pureenhanoi
175 100+
I'm trying to learn but, i need a kick to start on so if you can give me the code
it'll be a good kick for the start
Okey, thats the short discribe.
1. Create a connection to your database through DSN
+ Click on Start > Control Pannel > Administive Tools > Data Source (ODBC)
+ Select the tab System DSN and click Add
+ Scoll to the end of list and double click to SQL Server
+ Type Sample into Name textbox, and (local) to Server combobox (this will work if the SQL-Server was installed on your machine)
+ Click Next twice
+ Select the checkbox "Change the default database to". Choose your designed database from the combobox bellow and click Next. Then click Finish.
2. Goto visualbasic, create a new application
+ Select menu: Project > References
+ Check into Microsoft ActiveX Data Object 2.0 Library ( 2.0 or higher)
+ Create a new form with one textbox: Text1 and one command button Command1
+ Open the Code Designer, copy and paste bellow code into the form
Expand|Select|Wrap|Line Numbers
  1. Dim con As New ADODB.Connection
  2. Dim sql As String
  3.  
  4. Private sub Form_Load()
  5. con.Open "DSN=Sample"
  6. End Sub
  7.  
  8. Private Sub Command1_Click()
  9.  sql = "INSERT INTO tableName(columnName) VALUES '" & Text1.Text & "'"
  10.  con.Excute sql
  11. End Sub
  12.  
  13.  
Replace "tableName" with the name of the table that you want insert the data in
Replace "columnName" the the name of the field that will store the data.
The table from your database must have atleast one field (col) that named at tableName. (this field shouldnt be primarikey, and have datatype of Char or VarChar or NVarChar)
If you've known how to make the database from SQl-Server, so do like discribe above. If you have not, Save this reply for later use and learning how to make database first
Jul 28 '07 #5
Killer42
8,435 Expert 8TB
Thank you Verrrrrrrrrrrrrrry Much
. .
Jul 29 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lisa | last post by:
Hello, I am new to using recordsets, and i am completly stuck with this one. I am trying to use a multi select list box to write records to a table. Something in my code is causing the same...
3
by: Martin Horn | last post by:
Hi all, I am using VB2005 and the new data controls, which all work fine, except there is a situation where I want to add a new row to the database without using the 'AddNewItem' button on the...
2
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3=...
8
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to...
1
by: sal21 sal21 | last post by:
I use this code to update a sql database from excel to sql... Now i would want to arange this code to export an Access table into sql databse... Sub ADOExcelToSQLServer() Dim Cn As...
1
by: vivekvt | last post by:
-------------------------------------------------------------------------------- here is the code to the asp page that adds data to the access database! <html> <body> <% Dim recordsaffected
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
4
by: =?Utf-8?B?R3JlZw==?= | last post by:
My background is in MS Access and I am in the process of migrating my skillsets to Visual Basic.Net. So far I am able to display data in DataGridViews and Combo Box, etc with not problem. What I'm...
1
by: raaaz | last post by:
Hi dears, I am adding a record in Access database using AddNew method of recordset. here is the code of the page .. <% Set RsLibBuild = Server.CreateObject ("ADODB.Recordset")...
1
by: davidwelli | last post by:
Hello, I have a Access 200 format database that contains contact details and a picture for each record. The contact details are held in one table and the images are held in another as OLE...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.