473,587 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Command Parameters

Can someone tell me why the following code does not work ?

It does not crash or cause errors and it creates a new row in the table
"tblusers" but the fields are NULL.

Sub doInsert()
'Create Insert string
Dim MySQL As String = "Insert into tblusers (USERTEXT) values (@Pnotes)"
'Set up connection to mysql database
Dim myConn As OdbcConnection = New
OdbcConnection( "driver={MySql} ;uid=root;pwd=; server=127.0.0. 1;database=dbnr g
plc;OPTION=1792 3")
Dim Cmd As New OdbcCommand(MyS QL, myConn)
Cmd.Parameters. Add(New OdbcParameter(" @Pnotes", Me.txtNotes.Tex t))
myConn.Open()
Cmd.ExecuteNonQ uery()
myConn.Close()
End Sub

Thanks in Advance
Nov 17 '05 #1
1 1336
Paul,

Run the debugger and see if the text box actually has a value in it.

My guess is that your code is clearing the text box on post back.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Paul" <pa**@themedial ounge.com> wrote in message
news:ud******** *****@TK2MSFTNG P10.phx.gbl...
Can someone tell me why the following code does not work ?

It does not crash or cause errors and it creates a new row in the table
"tblusers" but the fields are NULL.

Sub doInsert()
'Create Insert string
Dim MySQL As String = "Insert into tblusers (USERTEXT) values (@Pnotes)" 'Set up connection to mysql database
Dim myConn As OdbcConnection = New
OdbcConnection( "driver={MySql} ;uid=root;pwd=; server=127.0.0. 1;database=dbnr g plc;OPTION=1792 3")
Dim Cmd As New OdbcCommand(MyS QL, myConn)
Cmd.Parameters. Add(New OdbcParameter(" @Pnotes", Me.txtNotes.Tex t))
myConn.Open()
Cmd.ExecuteNonQ uery()
myConn.Close()
End Sub

Thanks in Advance

Nov 17 '05 #2

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

Similar topics

4
11525
by: Cath B | last post by:
I am pretty sure I am getting a command timeout when execute a SQL procedure that has an output parameter. The code below is in an asp page that is called using RSGetASPObject. I want to be able to send a message back to the calling page to indicate that a timeout has occurred, but am having a hard time capturing the timeout error. I...
5
4366
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm stuck here.
0
2746
by: Elliot M. Rodriguez | last post by:
I implemented a very small, basic data access layer for my web application. It works just fine, except for this one bug. One of my methods returns an abstracted dataset. To accomodate X number of input parameters, I created a function signature that accepts a ParamArray of SqlParameters as well as the name of the stored proc. In the body of...
5
2217
by: Gene | last post by:
What can I do if I want to get the result using the sql command? for example, the select command is "select Name from Employee where StaffID=10" How to get the "Name"??? dim Name as string and then..... what should I do?
9
1902
by: orenr | last post by:
Hi We have a web site for 100 users using SQL Server. In our DAL all the selections when we need to pass parameters are using the SqlCommand and they are something like: SqlCommand com = new SqlCommand(); com.Connection = MyConnection; com.Transaction = MyTransaction; com.CommandText = ""SELECT CustomerID, CompanyName FROM Customers "
5
4825
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same principle I'd use if it was an sql database but I'm getting an error telling me the syntax of the "insert into" command
2
2917
by: explode | last post by:
I made nova oledbdataadapter select update insert and delete command and connection veza. dataset is Studenti1data, I made it by the new data source wizard,and made datagridview and bindingsource draging Table1 to Form2. The select command works fine, but when I change the data and call update command I get a syntax error: ...
3
4698
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder but eventually i wrote out the entire command my self, and still nothing. The only thing that i can think this that because i am trying to add a...
1
5175
by: Selvakumar | last post by:
hai friends, I am new to .net programming. I did the inserting data into MS-access database but i couldn't able to perform the update command. I used only textbox and command button for inserting and updating the data. I performed Insert command successfully but i donno y the update command is not working.Pls help.. i ve used all possible...
3
2464
by: Sagar | last post by:
Hi. I am working on a project to migrate a web application from 1.1 to 2.0 Within in the DAL of the application, there is a call to below function that builds a command object for later use. Inside this function iam getting a runtime error when the command object calls the prepare method.
0
7923
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...
0
8349
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
7974
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
8221
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...
1
5719
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...
0
5395
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
3845
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.