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

insert data with vb

idsanjeev
241 100+
this code repred error
ERROR [42000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-00936: missing expression
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <%@ import Namespace="System.Data.ODbc" %>
  3. <%@ import Namespace=" System.Data" %>
  4. <script runat="server">
  5.  
  6.     Sub submit(sender As Object, e As EventArgs)
  7.        ' lbl.text= "hello" &id.text
  8.         'txt.text= "hello" &id.text
  9.      dim dbconn
  10.      dbconn=New ODbcConnection("dsn=oracle;uid=starter;pwd=starter;")
  11.     dbconn.Open()
  12.         dim isql,idbread,idbcomm
  13.         isql="Insert Into students(id,first_name,last_name,major) values (@fname,@id,@lname,@major)"
  14.         idbcomm=new odbccommand(isql,dbconn)
  15.         idbcomm.Parameters.Add( "@fname",fname.text)
  16.      idbcomm.Parameters.Add( "@id",id.Text)
  17.      idbcomm.Parameters.Add( "@lname",lname.Text)
  18.      idbcomm.Parameters.Add( "@major",major.Text)
  19.      idbcomm.ExecuteNonQuery()
  20.      dbconn.Close()
  21.      End Sub
  22.  
  23. </script>
  24. <html>
  25. <head>
  26. </head>
  27. <body>
  28.     <form runat="server">
  29.         <th>Id Number:</th>
  30.         <asp:TextBox id="id" runat="server"></asp:TextBox>
  31.         <br />
  32.         <br />
  33.         <th>MaJor:</th>
  34.         <asp:TextBox id="major" runat="server"></asp:TextBox>
  35.         <br />
  36.         <br />
  37.         <th>First Name:</th>
  38.         <asp:TextBox id="fname" runat="server"></asp:TextBox>
  39.         <br />
  40.         <br />
  41.         <th>Last Name:</th>
  42.         <asp:TextBox id="lname" runat="server"></asp:TextBox>
  43.         <br />
  44.         <asp:Label id="lbl" runat="server" text="Label" width="80px"></asp:Label>
  45.         <br />
  46.                 <br />
  47.         <th>Last Name:</th>
  48.         <asp:TextBox id="txt" runat="server"></asp:TextBox>
  49.         <br />
  50.         <hr />
  51.         <asp:Button id="Button1" onclick="submit" runat="server" Text="Submit"></asp:Button>
  52.     </form>
  53. </body>
  54. </html>
Jun 28 '08 #1
8 2451
Line 13 looks odd, fname is being inserted into the ID field.
Jun 28 '08 #2
idsanjeev
241 100+
Line 13 looks odd, fname is being inserted into the ID field.
thanks
i try to change that like after creating new table
Expand|Select|Wrap|Line Numbers
  1.     dbconn.Open()
  2.         dim isql,idbread,idbcomm
  3.         isql="Insert Into stud(id,firstname,lastname,major) values (@id,@fname,@lname,@major)"
  4.         idbcomm=new odbccommand(isql,dbconn)
  5.         idbcomm.Parameters.Add( "@id",id.Text)        
  6.         idbcomm.Parameters.Add( "@fname",fname.text)
  7.         idbcomm.Parameters.Add( "@lname",lname.Text)
  8.         idbcomm.Parameters.Add( "@major",major.Text)
  9.         idbcomm.ExecuteNonQuery()
  10.         dbconn.Close()
  11.      End Sub
Jun 30 '08 #3
idsanjeev
241 100+
now i am strugling with same error
Jul 1 '08 #4
Frinavale
9,735 Expert Mod 8TB
thanks
i try to change that like after creating new table
Expand|Select|Wrap|Line Numbers
  1.     dbconn.Open()
  2.         dim isql,idbread,idbcomm
  3.         isql="Insert Into stud(id,firstname,lastname,major) values (@id,@fname,@lname,@major)"
  4.         idbcomm=new odbccommand(isql,dbconn)
  5.         idbcomm.Parameters.Add( "@id",id.Text)        
  6.         idbcomm.Parameters.Add( "@fname",fname.text)
  7.         idbcomm.Parameters.Add( "@lname",lname.Text)
  8.         idbcomm.Parameters.Add( "@major",major.Text)
  9.         idbcomm.ExecuteNonQuery()
  10.         dbconn.Close()
  11.      End Sub
The error you've specified indicates that you're missing a part of your SQL command. Looking at your Insert Into statement, everything looks okay...so long as there is a table named "stud".


Try putting in spaces after your commas in your command:

isql="Insert Into stud(id, firstname, lastname, major) values (@id, @fname, @lname, @major)"


Does your stud table only have columns: id, firstname,lastname,major? Or does it contain others?

-Frinny
Jul 1 '08 #5
idsanjeev
241 100+
the tbales creation scripts is
CREATE TABLE STUD
(
ID VARCHAR2(5),
FIRSTNAME VARCHAR2(20),
LASTNAME VARCHAR2(10),
MAJOR VARCHAR2(10)
)

so no any other fields in it also try to putting space but getting same error
Jul 2 '08 #6
DrBunchman
979 Expert 512MB
Does the sql work if you run it against the database in a query analyser?

Have you tried removing the parameters and using the value of your controls in the string directly? e.g.
Expand|Select|Wrap|Line Numbers
  1.  
  2. values ('" & id.Text & "', '" & fname.text & "', etc
  3.  
Are you certain that all your controls contain a value at this point?

Dr B
Jul 2 '08 #7
idsanjeev
241 100+
Expand|Select|Wrap|Line Numbers
  1.  
  2. values ('" & id.Text & "', '" & fname.text & "', etc
  3.  
Are you certain that all your controls contain a value at this point?
Dr B
hello Dr B
this code is working fine
Expand|Select|Wrap|Line Numbers
  1.  
  2. values ('" & id.Text & "', '" & fname.text & "', etc
  3.  
but i wnats ot know whats are the porblems in my code with
Expand|Select|Wrap|Line Numbers
  1. idbcomm.Parameters.Add( "@id",id.Text) 
  2.  
Regards
jha
Jul 2 '08 #8
idsanjeev
241 100+
the modified code is worked
Expand|Select|Wrap|Line Numbers
  1.         isql="Insert Into stud(id, firstname, lastname, major) values (?, ?, ?, ?)"
  2.         idbcomm=new odbccommand(isql,dbconn)
  3.         idbcomm.Parameters.Add("id", id.Text)       
  4.         idbcomm.Parameters.Add("fname", fname.text)
  5.         idbcomm.Parameters.Add("lname", lname.Text)
  6.         idbcomm.Parameters.Add("major", major.Text) 
  7.         idbcomm.ExecuteNonQuery()
  8.  
i think @ is not worked with odbc .
I am not sure .
if any idea?
Regards
jha
Jul 2 '08 #9

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

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
2
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
2
by: wombat53 | last post by:
Hi Group Are there any DB2 UDB ESE DPF V8.2 users exploiting "buffered inserts" (BIND parm INSERT BUF) *and* "multi-row INSERTS" (many rows associated with the VALUES clause of the INSERT to...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.