473,769 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Odbc parameter error

Hii all i have written following code for inserting records into
database but it gives me an error espected parameter @NewsTitle which
is not supplied.

OdbcConnection conn = new OdbcConnection( );
protected System.Web.UI.W ebControls.Butt on Button1;
OdbcCommand cmd =new OdbcCommand ();
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Text Box TextBox2;
OdbcParameter param =new OdbcParameter() ;

//class constructor
public TestAddRec()
{

conn.Connection String="DSN=vri tti;uid=sa;pwd= sa";
cmd.Connection= conn;
conn.Open();
}

private void Button1_Click(o bject sender, System.EventArg s e)
{

cmd.CommandType =CommandType.St oredProcedure;
cmd.CommandText ="DS_SP_Insert_ News";

param.OdbcType= OdbcType.VarCha r;
param.Value = "@TextBox1.Text ";
param.SourceCol umn="@NewsTitle ";

//param.Parameter Name="Param1";
cmd.Parameters. Add(param);
OdbcParameter param1 =new OdbcParameter() ;
param1.OdbcType =OdbcType.VarCh ar;
param1.Value = "@TextBox2.Text ";
param1.SourceCo lumn="@NewsDesc ";
//param.Parameter Name="Param2";
cmd.Parameters. Add(param1);

OdbcParameter param2 =new OdbcParameter() ;
param2.OdbcType =OdbcType.DateT ime;
param2.Value = DateTime.Now.To ShortDateString ();
param2.SourceCo lumn="@Modified Date";
//param.Parameter Name="Param3";
cmd.Parameters. Add(param2);

OdbcParameter param3 =new OdbcParameter() ;
param3.OdbcType =OdbcType.Date;
param3.Value = DateTime.Now.To ShortDateString ();
param3.SourceCo lumn="@AddedDat e";
//param.Parameter Name="Param4";
cmd.Parameters. Add(param3);

OdbcParameter param4 =new OdbcParameter() ;
param4.OdbcType =OdbcType.VarCh ar;
param4.Value = "Santosh";
param4.SourceCo lumn="@AddedBy" ;
//param.Parameter Name="Param5";
cmd.Parameters. Add(param4);
cmd.ExecuteNonQ uery();
Response.Write( "<Script language=javasc ript>alert('Rec ords are added
successfully'); </script>");
}

Oct 5 '06 #1
2 2496
Looking at your parameters and how NewsTitle compares to your other parameters,
perhaps it's due to the fact that a new OdbcParameter hasn't been instanciated
for NewsTitle inside the button1_click. Have you tried moving it in there?

** OdbcParameter param = new OdbcParameter() ; **
param.OdbcType= OdbcType.VarCha r;
param.Value = "@TextBox1.Text ";
param.SourceCol umn="@NewsTitle ";

//param.Parameter Name="Param1";
cmd.Parameters. Add(param);

If not, is there a reason it's left outside?

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
Hii all i have written following code for inserting records into
database but it gives me an error espected parameter @NewsTitle which
is not supplied.

OdbcConnection conn = new OdbcConnection( );
protected System.Web.UI.W ebControls.Butt on Button1;
OdbcCommand cmd =new OdbcCommand ();
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Text Box TextBox2;
OdbcParameter param =new OdbcParameter() ;
//class constructor
public TestAddRec()
{
conn.Connection String="DSN=vri tti;uid=sa;pwd= sa";
cmd.Connection= conn;
conn.Open();
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
cmd.CommandType =CommandType.St oredProcedure;
cmd.CommandText ="DS_SP_Insert_ News";
param.OdbcType= OdbcType.VarCha r;
param.Value = "@TextBox1.Text ";
param.SourceCol umn="@NewsTitle ";
//param.Parameter Name="Param1";
cmd.Parameters. Add(param);
OdbcParameter param1 =new OdbcParameter() ;
param1.OdbcType =OdbcType.VarCh ar;
param1.Value = "@TextBox2.Text ";
param1.SourceCo lumn="@NewsDesc ";
//param.Parameter Name="Param2";
cmd.Parameters. Add(param1);
OdbcParameter param2 =new OdbcParameter() ;
param2.OdbcType =OdbcType.DateT ime;
param2.Value = DateTime.Now.To ShortDateString ();
param2.SourceCo lumn="@Modified Date";
//param.Parameter Name="Param3";
cmd.Parameters. Add(param2);
OdbcParameter param3 =new OdbcParameter() ;
param3.OdbcType =OdbcType.Date;
param3.Value = DateTime.Now.To ShortDateString ();
param3.SourceCo lumn="@AddedDat e";
//param.Parameter Name="Param4";
cmd.Parameters. Add(param3);
OdbcParameter param4 =new OdbcParameter() ;
param4.OdbcType =OdbcType.VarCh ar;
param4.Value = "Santosh";
param4.SourceCo lumn="@AddedBy" ;
//param.Parameter Name="Param5";
cmd.Parameters. Add(param4);
cmd.ExecuteNonQ uery();
Response.Write( "<Script language=javasc ript>alert('Rec ords are
added
successfully'); </script>");
}

Oct 5 '06 #2
i have tired in other ways also but still it is giving same error . if
i am using sqlconnection, sqlcommand, sqlparameters then it works fine
but it gives an error when i am using Odbc.

--
David R. Longnecker wrote:
Looking at your parameters and how NewsTitle compares to your other parameters,
perhaps it's due to the fact that a new OdbcParameter hasn't been instanciated
for NewsTitle inside the button1_click. Have you tried moving it in there?

** OdbcParameter param = new OdbcParameter() ; **
param.OdbcType= OdbcType.VarCha r;
param.Value = "@TextBox1.Text ";
param.SourceCol umn="@NewsTitle ";

//param.Parameter Name="Param1";
cmd.Parameters. Add(param);

If not, is there a reason it's left outside?

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
Hii all i have written following code for inserting records into
database but it gives me an error espected parameter @NewsTitle which
is not supplied.

OdbcConnection conn = new OdbcConnection( );
protected System.Web.UI.W ebControls.Butt on Button1;
OdbcCommand cmd =new OdbcCommand ();
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Text Box TextBox2;
OdbcParameter param =new OdbcParameter() ;
//class constructor
public TestAddRec()
{
conn.Connection String="DSN=vri tti;uid=sa;pwd= sa";
cmd.Connection= conn;
conn.Open();
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
cmd.CommandType =CommandType.St oredProcedure;
cmd.CommandText ="DS_SP_Insert_ News";
param.OdbcType= OdbcType.VarCha r;
param.Value = "@TextBox1.Text ";
param.SourceCol umn="@NewsTitle ";
//param.Parameter Name="Param1";
cmd.Parameters. Add(param);
OdbcParameter param1 =new OdbcParameter() ;
param1.OdbcType =OdbcType.VarCh ar;
param1.Value = "@TextBox2.Text ";
param1.SourceCo lumn="@NewsDesc ";
//param.Parameter Name="Param2";
cmd.Parameters. Add(param1);
OdbcParameter param2 =new OdbcParameter() ;
param2.OdbcType =OdbcType.DateT ime;
param2.Value = DateTime.Now.To ShortDateString ();
param2.SourceCo lumn="@Modified Date";
//param.Parameter Name="Param3";
cmd.Parameters. Add(param2);
OdbcParameter param3 =new OdbcParameter() ;
param3.OdbcType =OdbcType.Date;
param3.Value = DateTime.Now.To ShortDateString ();
param3.SourceCo lumn="@AddedDat e";
//param.Parameter Name="Param4";
cmd.Parameters. Add(param3);
OdbcParameter param4 =new OdbcParameter() ;
param4.OdbcType =OdbcType.VarCh ar;
param4.Value = "Santosh";
param4.SourceCo lumn="@AddedBy" ;
//param.Parameter Name="Param5";
cmd.Parameters. Add(param4);
cmd.ExecuteNonQ uery();
Response.Write( "<Script language=javasc ript>alert('Rec ords are
added
successfully'); </script>");
}
Oct 6 '06 #3

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

Similar topics

2
13645
by: GitarJake | last post by:
Hello all, I am trying to test an ODBC connection to an Oracle dbf using the ODBC Data Source Administrator. It's not working and I suspect I haven't configured Oracle correctly. Below is the error message I am getting: Invalid attribute in connection string: Description.ORA-12514: TNS:listener could not resolve SERVICE_NAME given in connect descriptor
4
7251
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript to make ODBC calls to the db. The particular system I'm working with, will not work with an Oracle stored procedure I'm told. However, it
4
18058
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out on me for some reason. The Summary field is pulled from a Rich Text Editor that allows HTML formatting and appears to be the culprit, but I just can't seem to figure out why. Any guidance is greatly appreciated. I'm connecting to an Access...
5
6191
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select from the cli is for all intents practicaly instantaneous. After much research I discovered that PHP by default uses a dynamic cursor type which can be quite a bit slower than a forward only cursor. BTW I have been searching forward only/read...
2
1915
by: Bibi | last post by:
Hi, i have a SqlWindows Program which made a connection to a MS Access Database about ODBC. I can get all datas with a select about one table. But when i made a select with more than one table, i get the following message: "ACCESS:-3010 1 Parameter wurden erwartet, aber es wurden zu wenig Parameter übergeben." Can somebody help me ?
1
1645
by: TheKval | last post by:
I'm trying to pull records on a Macola table linked to Access. If enter a value in the criteria field of the query form, the quer executes okay. If I change the criteria to a parameter, ala, , I get the ODBC... call failed error. The data ite is a 3 character text field. I've tried to us the parameter AFTE trimming the table field. no luck Any helpful hints? :
0
1759
by: Marco Martin | last post by:
Hi group, I have an app that accesses an Access DB. We are using odbc because this app will probably be using other databases as well dependiing on the clients needs. Consider the following; OdbcParameter prmID = new OdbcParameter("ID", OdbcType.Text);//ID column is Primary Key
3
4611
by: juststarter | last post by:
Hello all, I am executing a stored procedure (on an SQL Server) using ODBC but i can't get the output parameter's value on the client. The stored proc has 3 parameters ,2 of them are input and 1 is output. (for shake of simplicity let's suppose that the proc seems something like -------------------------------------------------------------------- alter storedProcsName @inputParam1 varchar(20), @inputParam2 varchar(20), @outputParam...
1
10340
by: chloe.crowder | last post by:
Hi We're trying to use call a stored procedure to update information in a remote Ingres database. We've linked the server, and can read information using SELECT * FROM OPENQUERY (..........), but we can't find a suitable syntax for executing a procedure. Using SELECT * FROM OPENQUERY and passing the EXEC statement in a string gives a message about not returning any columns - not surprising as there aren't any, and trying to execute...
4
10082
by: Szymon Dembek | last post by:
Hi Recently I did some DB2 and ODBC coding in Visual FoxPro. I bumped on a problem I cannot resolve. When I issue a delete statement that deletes no rows (no rows qualify for the WHERE conditions), DB2 raises SQL0100W warning with SQLSTATE=02000. The same happens when issuing an insert with select clause (insert into .... select from ...) when no rows are fetched by the select clause.
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10043
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.