473,569 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help me debug

33 New Member
help 'e debug
--------------------------------------------------------------------------------

I wrote the below code to input new data from name and address textbox of a form to microsoft access but there are alot of error. the name of the table in the access is Hotel and the the fields are HotelName and HotelAddress . Please can somebody help me and debug. i used vb.net

Note: almost all the line is underlined with red line indicating incorrect declaration and so on. please help me debuge. i know is also possible you set OleDb connection and OleDbAdapter and then write a few line code to input data into database. how do i write the code. please help me


Expand|Select|Wrap|Line Numbers
  1. Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3.  
  4.         Dim Objconn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector  y|\ECBInvoicing.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
  5.         Objconn.Open()
  6.  
  7.         ObjCmd = New SqlCommand("INSERT INTO hotel (HotelName, HotelAddress) VALUES (@HotelName, @HotelAddress)", Objconn)
  8.  
  9.  
  10.         ObjCmd.Parameters.Add("@HotelName", Data.SqlDbType.VarChar).Value = txtHotelname.Text
  11.         ObjCmd.Parameters.Add("@HotelAddress", Data.SqlDbType.VarChar).Value = txtHotelAddress.Text
  12.  
  13.  
  14.         ObjCmd.ExecuteNonQuery()
  15.  
  16.  
  17.         Objconn.Close 
  18.     End Sub
Jun 24 '07 #1
1 1038
vanc
211 Recognized Expert New Member
To query access database you should use System.Data.Ole Db namespace
and create connection
OleDbConnection connection = new OleDbConnection (@"Provider=Mic rosoft.Jet.OLED B.4.0;" +
" User Id=; Password=; Data Source="mdb file name")

Create command
OleDbCommand command = connection.Crea teCommand()
command.Command Text = ""

Create DataReader
OleDbDataReader reader = command.Execute Reader();

cheers.
Jun 25 '07 #2

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

Similar topics

1
2949
by: jasper | last post by:
hi, i am trying to make a very simple program that will just detect and output your currently connected IDE devices. It will look something like this: IDE PRIMARY MASTER: IDE PRIMARY SLAVE: IDE SECONDARY MASTER:
3
2968
by: Mahmood Ahmad | last post by:
Hello, I have written a program that reads three types of records, validates them acording to certain requirements and writes the valid records into a binary file. The invalid records are supposed to be reported on the printer but I have commented those pieces of code and have got those records printed on the screen. I am using Microsoft...
1
574
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h #--------------------------- #include <io.h> #include <ctime> #include <string>
9
5158
by: tym | last post by:
HELP!!! I'm going round the twist with this... I have a VB6 application which is using DAO to access a database (Please - no lectures on ADO, I know what I'm doing with DAO!!) Ok, problem is this.... importing a large csv file (189000 lines, 7 fileds per line)
4
2653
by: VicVic | last post by:
Dear Great Experts, I have a problem and need your help! We have a Flat DLL built in C++ (CCC), and on top of it, we built another DLL built in C# (SSS), which has .Net Assembly. CCC was imported into SSS. Now we build applications using SSS as a reference, and we found some problems exist in CCC. From our applicatyion, We can Debug...
4
1439
by: Marek Krzeminski | last post by:
I am new to ASP and I am having some problems that I hope someone can help me with. I am using WindowsXP and a book to try to learn ASP. The book instructed me to install IIS & .Net Framework v1.1 (which I did) In the book they gave me the following code: <script language="vb" runat="server">
43
2195
by: ZillionDollarSadist | last post by:
Hello, I'm working at a simple Access '97 + VB4 application, and I ran into a terrible problem: something I never modified now gives me a totally unwanted "Invalid use of null" error. It happens in a Text.LostFocus event, this block: Do While Not TB6.EOF If Year(TB6(0)) = Val(Trim(Text1.Text)) Then !!!!!!!!!!!!!Here!!!!!!!!! ...
0
1120
by: bchirra | last post by:
I am trying to convert following function into .net using System.net.WebRequest class, can any one please help. Thank you very much. Public Function PostForm(ByVal server As String, ByVal CGI As String, ByVal Request As String) As String On Error GoTo myError Dim hOpen As Long, hConnection As Long Dim hURL As Long ...
2
1926
by: theronnightstar | last post by:
I am writing an anagram program for my fiance. Figured it would be an excellent task to learn from. The way it is supposed to work is it reads in a word list from a file into a temporary vector<string>. From that it selects a random word 6 letters or more long. That is the word of the game - the one to make all the anagrams from. After it...
16
2297
by: Harry Simpson | last post by:
I've been away from ASPNET - I open up a new Web app in VS2008 and go into properties and select to use IIS instead of the personal web server. Then I run in debug mode and it says I have to set the Debug= True in the Web.config which I do. Then try to run it again and it says I must enable integrated security which I do. I then try to run...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.