Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2004, 07:02 AM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting into database

Hi AGAIN,

I used this code in a another program I wrote and it worked, now it doesn't... Any ideas ?

Code:
try
{
    myConnection.Open();
    Adapter1.InsertCommand.Parameters["nafn"].Value = nafnaBox.Text;
    Adapter1.InsertCommand.Parameters["heimilisfang"].Value = heimilisfangaBox.Text;
    Adapter1.InsertCommand.Parameters["simi"].Value = simaBox.Text;
    Adapter1.InsertCommand.Connection = myConnection;
    Adapter1.InsertCommand.ExecuteNonQuery();
    myConnection.Close();
}
catch (Exception)
{
    MessageBox.Show("Some catch going on");
}
 
Old July 1st, 2004, 09:30 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How doesn't it work? Error messages? Can you provide more details?
 
Old July 1st, 2004, 09:31 AM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It just went into the catch branch, so I took out the try & catch and saw the error message and realized I was missing the @ sign infront of the parameter names.... sry

 
Old July 1st, 2004, 09:43 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Aha! See my response was to help you trouble shoot the problem, using the old adage "if you give a man a fish...".

(Actually, I missed the @s myself! )
 
Old July 1st, 2004, 09:45 AM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah you got me thinking in the right direction, thanks alot for your time, I appriciate it alot, I am learning so much and so quickly, just started messing around with Visual programming a week ago, have quite a good experiance in the old C++ console programming....

 
Old July 3rd, 2004, 03:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I suggest to use catch part as
Code:
catch (Exception Ex)
{
    MessageBox.Show(Ex.Message);
}
to see what is the problem & solve it.

Keep in touch...

Always:),
Hovik Melkomian.
 
Old July 5th, 2004, 04:13 AM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Will do, thanks for the tip






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in inserting to Database?? Hannibal Pro JSP 0 March 14th, 2006 07:11 AM
Inserting into a database jroxit Classic ASP Basics 1 January 2nd, 2006 06:04 PM
inserting into database shieldsteven VS.NET 2002/2003 0 November 11th, 2004 07:44 PM
inserting into database shieldsteven VS.NET 2002/2003 8 October 20th, 2004 05:33 PM
Inserting VBNullChar into a database ipclogistics SQL Language 1 June 11th, 2004 10:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.