Elmo_loves_you 20 Junior Poster in Training

Hey Guys, I've been away from Dev for a while, just getting back into it now and not sure if there are many Kentico genius' throughout Daniweb ... but I am a bit stuck and need a wee bit of much appreciated help if you can, many thanks

I am fairly new to Kentico and I am not 100% sure how to prevent a product option from displaying on the frontend website, but keeping it enabled in the backend so the system admins can still place orders using the option.

For example

CMSDesk > Tools > Ecommerce > Product Options > Edit an option which has child options

Eg, there are three child options, two of which I want displayed to the user on the website, but only one of them I want to hide from the end user and ONLY allow the Administrator to have access to the option...

Has anyone ever had the need for this feature before? If so, how did you accomplish it?

Thanks

Michelle

Elmo_loves_you 20 Junior Poster in Training

thanks for your reply

I'm very new to php, so I automatically started trying to think of a solution in a syntax I was familiar with (sort of - I have a lot to learn)

I was thinking maybe about using javascript 'prototype' to overwrite the css style applied with a new one based on a certain type ...

Elmo_loves_you 20 Junior Poster in Training

Hey everyone.

I haven't been on DaniWeb in a while.

.x-accordion-header {
	width: 100%;
	color: #ffffff;
	background-image: -webkit-gradient(linear,0% 0,0% 100%,color-stop(0%,#[B]96A9C0[/B]),color-stop(2%,#[B]5A7596[/B]),color-stop(100%,#[B]394B5F[/B]));
}

Is it possible to include a 'variable' or 'property' in css?

The reason why I am asking is because I want to change the background colour of the css header for multiple object types.

Say I checked for the type either via PHP or Javascript with a case statement or an IF ELSE ... I would want to be able to assign a certain colour based on the object type to the headers css.


Any hints or tips or suggestions would be appreciated.


Many Thanks
:-/

Elmo_loves_you 20 Junior Poster in Training

If you are capturing images then you will probably want to store them in a database as a BLOB (Binary Large Object) or on your computer with a path to the images stored in the database.


You are just going to have to read up on the subject area and find out what options are available to you ...

... its a lot of donkey work for a "new area of coding" but the only way you are going to learn is by trying it yourself first ... them when you are really stuck and cant find the answer but have a strong basis to work from ... then you might be able to get some helpful guidance from the forum ... you wont get the code handed to you in a great big project zipped folder for you to claim as your own!

Salem commented: Well said +22
Elmo_loves_you 20 Junior Poster in Training

Hey Everyone

Is it possible to disable the dates that appear before todays date in a dateTimePicker control?

I want to put in some validation so that my users can only select days in the future...ie a future appointment date

Any ideas ?


Thanks

Elmo_loves_you 20 Junior Poster in Training

Hi Guys


Does anyone have any ideas on how to do this?

Elmo_loves_you 20 Junior Poster in Training

Heya

I have to write a script within MS Access 2003 using Visual Basic for Applications to read in data from a textfile and insert it into the table. I began my programming path using dot.Net C# and started database manipulation using Sql Server. So this is kind of like a step backwards for me ... Im so used to seeing the intellisense pop up all the time to help me out.

I have previously set up a database (Insert, Update, Delete etc) using stored procedures and called them in the code accordingly. However, MS Access doesnt have stored procedures .. so I have been trying to use an ADODB.Command to insert data to the table.

I am reading data in from a specific file directory, once one file is finished reading to the end the next one is read etc... Im am pulling out the values and passing them into an array... so I want to be able to insert each individual element of the array into the database table now :)

Here is the code I have so far

Private Sub InsertAnswers(ByVal strSpecialist As String) 'For testing the rest have been removed
'Insert a new row
    On Error GoTo ErrorHandler
    'Connection Variable
    Dim strSQL As String
    Dim insert_conn As ADODB.Connection
    Set insert_conn = New ADODB.Connection
    insert_conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    insert_conn.Open "C:\Users\User\Documents\Current Projects\myDatabase.mdb"    

'Command Variables
    Dim insert_Command As ADODB.Command
    Set insert_Command = New ADODB.Command
    inset_Command = "INSERT INTO FactFind(Specialist) VALUES(@specialist)"
   
   'Declare and Initialise Parameters
    Dim …
Elmo_loves_you 20 Junior Poster in Training

Hi Guys

I have managed to write values to a Windows Mobile CE Registry Editor from my application.

I have a writeIniReg() and a readIniReg() function

So, when the user enters their name in the textbox on the form it is written to the registry and read from it again the next time the user runs the program.

But my problem is that my readIniReg() gets a NullReferenceException when the program first loads .... but if I comment out the readIniReg() and run it to write data to the registry then uncomment the code, it can read from it...


Can anyone help me to check in my readIniReg() if the subKey folders exist first and create them if they dont exist ... so that I can get away from my error message.

Please even give some suggestions ... I still have a lot to learn with VB :)

Public Function readIniReg() As Boolean
        Dim localResult As Boolean
        Dim regKey As RegistryKey
        Dim regKeyCompany As RegistryKey
        Dim regKeyProduct As RegistryKey

        localResult = False

        regKey = Registry.CurrentUser.OpenSubKey("Software", True)
        regKeyCompany = regKey.OpenSubKey("Company", True)
        regKeyProduct = regKeyCompany.OpenSubKey("Data", True)

        'Name of value to return
        strName = regKeyProduct.GetValue("Username").ToString()
        'Pass username string variable to form1 variable
        Form1_LogIn.username = strName
        'Display Name in the textbox
        Form1_LogIn.txt_user.Text = strName


        'Close all keys
        regKeyCompany.Close()
        regKeyProduct.Close()
        regKey.Close()

Regards

Elmo

Comatose commented: Taste It -2
Elmo_loves_you 20 Junior Poster in Training

Hey Guys

Sorry for digging up this thread .. but is it possible to design a Form in Photoshop and then make the various buttons do something within Visual Studio as a mobile application .. not a website???

If so ... how ??

Elmo_loves_you 20 Junior Poster in Training

Hi Guys...

Ive had a brainwave .. or at least want to try a different approach.

I want to keep a count of all new files created ... possibly in the mobile devices registry ... or by XML file ....

so my application will boot up for the first time ... realise the count is 0 ... create a new file but increment the count by 1 and attach the number 1 to the new file name ...

Therefore, the next time my application runs, it will check the number in the registry/XML file and increment it by one ---- that way the files created will constantly increment by one each time ... making filenames unque

:) Please could someone help point me in the right direction to do this....

Many Thanks

Elmo

Elmo_loves_you 20 Junior Poster in Training

Hi Guys,

Im more familiar with coding in C# ... can someone please help me to convert the line highlighted below into VB.NET

Much appreciated

private int file_count = 0;
///
/// Get the file count of a given directory recursively.
///
public void GetDirectoryFileCount(string dir)
{
dir = dir + @”\”;
//get all the directories and files inside a directory
String[] all_files=Directory.GetFileSystemEntries(dir);
//loop through all items
[B]foreach(string file in all_files)[/B]
{
//check to see if the file is a directory if not increment the count
if(Directory.Exists(file))
{
//recursive call
GetDirectoryFileCount(file);
}
else
{
//increment file count
file_count++;
}
}
}
Elmo_loves_you 20 Junior Poster in Training

Hi ... im fairly new to this aswell so ...

if the date field in your database is set to dateTime then you have to add the date selected from the dateTimePicker in date format

Dim var As Date  'Declare a date variable
var = DateTimePicker1.Value.Date    'Get the date!

dr("BirthDate") = var

Something to that effect :)

Elmo_loves_you 20 Junior Poster in Training

Hey Guys, im a fairly novice programmer

I would just like to hear some views / opinions on how you would go about implementing the following:

I need my program to save data to a textfile giving the file a name and adding a number to the end eg filename_1.txt. So, each time my program runs it saves the data entered to a new textfile (incrementing the number each time)

The way I was thinking of implementing this was to :

1. Create a textfile named count.txt that just contains a number (the number of files created)

2. Each time a new file needs to be created, check the count.txt file to see what the number is, then increment it by one and append it to the new textfile name, then overwrite the number that was in count.txt

3. close the program when data has been entered (creating unique filename)

I have come up with this approach beacuse I need the program to be able to keep track of the number as the user will close the application and only load it when needed.


To me it seems to be a sensible approach, but there are more than likely more efficient ways of doing this. Your comments would be much appreciated

Kind Regards

Michelle

Elmo_loves_you 20 Junior Poster in Training
Dim p As New System.Diagnostics.ProcessStartInfo()
        p.FileName = "FactFind.exe"
        p.UseShellExecute = True
        System.Diagnostics.Process.Start(p)

I have tried the above code to start a process. forcing the application to start ... no joy however :(

Elmo_loves_you 20 Junior Poster in Training

well - - has anyone got any ideas ??

I really need to get this functioning. my last resort would be to remove the code that disables the buttons after each section has been completed.

Elmo_loves_you 20 Junior Poster in Training

Hi Guys ...

Does anybody know how to force a windows forms application to restart (Close and open again) taking the user back to the first screen ?

My user fills in a questionnaire, reaches the end and is asked to either perform another survey or to send data (sent back to HQ)

So, if they click to perform another survey ... I have got it to create seperate textfiles with incremented numbers file_1.txt, file_2.txt etc

but because I have disabled buttons within my program after the user completes each section .. they are unable to fill in any information for the second survey because the buttons have been disabled.

I was thinking it would have been something like

Application.restart()

but all I get is

Application.Exit()
Elmo_loves_you 20 Junior Poster in Training

Hi guys

I am able to add data to a textfile on a windows mobile device but can only get it to store within the 'My Device' folder.

I have tried to place it within folders ... but it cries with a NullReferenceException

Dim path As String = "\testFile.txt" 'Name of the File to be created

Private Sub btn_Proceed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Proceed.Click
        'Pass the data entered to the string variable
        If File.Exists(Path) = False Then
            'Create a file to write to
            sw = File.CreateText(Path)
            sw.Write("Text within the file: ")

Has anyone got any ideas please :)

Elmo_loves_you 20 Junior Poster in Training

Hi Guys

I hope you can help share some light on my problem.

Basically, I have a MS Access table...ID, firstname, surname, Address1, Address2 etc

What I want to do is Select all from table but only show one record where more than one person lives at that address .. Eg only sending one envelope to the one household rather than sending two to the same address ....

I wouldnt have thought it was overly complex, however the combinations that I have been trying from the query builder havent worked ..

I can get a count of the number of records where the same address exists but I can't display a first name aswell.

Your suggestions will be greatly welcomed ... Thanks

Elmo

Elmo_loves_you 20 Junior Poster in Training

OK - I've got the Form1 to create a new file and add data to it when a button is clicked.

I would like to add/append data from Form2 and Form3 etc to the file created on Form1.

I have tried using an instance of the Form1 so that I could access the path string and the streamwriter.... but not having much luck

please try to help to point me in the right direction

Elmo_loves_you 20 Junior Poster in Training

Just incase anyone is interested ... Ive found a thread that explains the mobile file structure and how to find the new file you just created ....

http://forums.msdn.microsoft.com/en-US/csharpgeneral/thread/5e689655-5fa2-42c9-bd0d-469303309953/

:)

Elmo_loves_you 20 Junior Poster in Training

Hi Guys,

Surely this shouldnt be such a complex task! I have done this before for a desktop application where I typed in data on the UI clicked a button and a new text file was created on the C: drive and the data added.

Ive been googling and googling and searching forum upon forum but Im not having much luck.

I have already set up a VB project but my C# skills are stronger so I felt it would be wise to get it working using a language im more familiar with before delving into the deep end.

Just to give an overview of what I am doing:

A sales rep conducts questionnaires with customers via pen and paper ... I have to modernise this approach so that it uses windows mobile 6.

Im rather new to mobile development and cant suss out how/where to store the NEW file on the device so that I can then attach the file to an email...

Please could someone help point me in the right direction for this, I would be very greatful

:) thanks

Elmo

Elmo_loves_you 20 Junior Poster in Training

Would it not be better to set the 'image' field in the database as an Image or VarBinary(max). Then to add an image to the database you could pass in the bytes of the new image file that you want to upload.

Thats the approach I used when I wanted to store documents/images in SQL Server

Elmo_loves_you 20 Junior Poster in Training

Hi lads (and ladettes)

I have to create a mobile application that gathers user input, saves it to a document so that it can then be emailed back to HeadQuarters.

Im new to this area ... although I have used the StreamWriter/StreamReader classes to create a new TextFile and save data to it and read from it. However, I cant seem to grasp this approach on a mobile application.

So, I have numerous forms with multiple textboxes for user input. What I want to do is collect all the data entered by the user and Write it to a text file ... but within the emulator I cant suss out where/how the file would save to so that could check it to verify that the data actually did save to it.


Has anyone got any suggestions? They would be greatly appreciated.

I considered adding the data to a database and then calling the content and constructing an email using the new data.. however it seems to be too advanced for the needs of my application (I think)

Elmo_loves_you 20 Junior Poster in Training

Thank you VERY much Dickersonka :)

:S I will look into this ... I greatly appreciate the assistance you have given me.

Have a virtual hug lol :)

Elmo_loves_you 20 Junior Poster in Training

You need to set the server to be in mixed mode authentication.

Go to properties for server, then click security and change it to mixed mode.

Then restart sql server.

If that doesn't allow you in, make sure the username is valid.

OK am I missing something?

By server in mixed mode, what do you mean? At the minute I have no idea of which server the end result of this system will be loaded on to.

Properties of Server ?? -

Let me try and explain what I am doing. I am currently doing all my work inside Visual Studio. I created my SqlExpress Database by right clicking on the project name and adding a new item (the database).

Then I basically followed the defaults, keeping windows authentication until my database folder was displayed under 'Data Connections' in the 'Server Explorer' tab of Visual Studio.

Now if I right-click on the database name listed under 'Data Connections' and select 'Modify Connection' I get a pop up window informing me of the Data Source, Database file name (new or existing) and a group box containing 2 radio buttons. One says use 'Windows Authentication' and the other says 'Use Sql Server Authentication' and shows a Username and Password textbox. There is also a 'Test Connection' button which tells me that whatever I type in is not associated with Sql Server.


Does this mean that I have to get someone to create a new …

Elmo_loves_you 20 Junior Poster in Training

Hiya,

Ok, so inside the 'Server Explorer' tab of the Visual Studio IDE I right clicked on the database.mdf file and clicked 'Modify Connection'. I then changed the radio button to 'Use SQL Server Authentication'.

I then typed in a 'new' user name and password and clicked 'Test Connection' but got an error message saying:

Login failed for user 'admin'. The user is not associated with a trusted SQL Server connection.

Can you point me in the right direction for this problem please.

Elmo_loves_you 20 Junior Poster in Training

Depends how you setup the initial connection.

but, if you just mean to use username/password authentification to connect to the sql server it shouldnt be hard.

Yes initially I chose Windows Authentication to set up the connection to the database as I naively thought it shouldnt matter for developing the system, but I need to change it to use the Username and Password ... for that approach do I need an actual physical server to tell my database to connect to ? Or am I looking at this the wrong way?

Elmo_loves_you 20 Junior Poster in Training

Hi

I have just been informed by a few work collegues that the database system that I have created should now be set to use Server Username and Password.

Is it a big deal to change this without disrupting the current relationship of the database stored procedures and application code?

Or can it even be done? Would I have to set up the database again to use the server settings?

Elmo_loves_you 20 Junior Poster in Training

Hi

I have just discovered a development environment called MobiForms available at http://www.mobiforms.com/ for developing mobile applications.

I had a wee read through it but cant see any real differences with in compared to visual studio emulators in terms of developing RAD forms (drag n drop controls)

Has anyone got any opinions regarding this? Which one would you opt for yourself?

Kind Regards

Elmo

PS. I couldnt find a mobile forum to put this thread :)

Elmo_loves_you 20 Junior Poster in Training

Hi Guys

I have a stored procedure where I am adding a new record to a table and I have RETURN SCOPE_IDENTITY() at the end...on testing it returns the ID value that I want. However I want to be able to use this ID value and pass it to a variable within my C# code which I could then use to pass into another stored procedure to add data to a new table.

command.ExecuteNonQuery();
            command.ExecuteScalar();
            i_VehicleID = (int)command.ExecuteScalar();

The code snippet above shows how I have tried to store the integer value in a variable.

I would be so grateful for some assistance :)

Elmo_loves_you 20 Junior Poster in Training

It might be MSSQLSERVER or SQLEXPRESS

Hi, that program requires Oracle client and networking components! Why is that if im only using SQL Server

Elmo_loves_you 20 Junior Poster in Training

Hmmm ok

Im stiil trying to figure out how to set that up properly ... Teratrax Performance Agent > Server Configuration > SQL Server Instance name.

Elmo_loves_you 20 Junior Poster in Training


Are you sure the code is running as the same user as your login?

Actually no im not sure lol :) My login is simply textboxes and I then programatically check that what the user enters matches a set username and password.

I have it set up on the one machine ... and Im able to successful add a new customer record to the customer table. So I cant see why it should be any different to add a new vehicle record and then add the primary key from each table to a new (in-between) table.

Elmo_loves_you 20 Junior Poster in Training

OK thanks

Do you know of any tools available to VS2008 and Sql Server 2005 that may help me

Elmo_loves_you 20 Junior Poster in Training

Case sensitive?

Ive double checked the case and the spelling...thats all correct!

Ive been reading about a tool called Sql Profiler, its not available on my machine, I have tried googling for it and came across Teratrax Performance Agent 7 day trial version...but Im not making much sense of it.

I seen on the MSDN forum somewhere that someone else was having the same problem as me, and they were told to run the Sql Profiler program to diagnose the problem by clicking Sql Server > Performance Tools > Profiler ... but I cant find that

Elmo_loves_you 20 Junior Poster in Training

Hi

I have run my program again, and even created a new stored procedure containing the same code that "does what it says on the tin" while executed within the stored procedure itself. It adds to the database.

However, my code bugs out saying that it cant find the stored procedure!!

Why would it be doing that? Anyone have any ideas?

I have attached a wee screen shot of the line where it bugs out, the SqlException and proof that the stored procedure exists lol

please help :)

Elmo_loves_you 20 Junior Poster in Training

hi all,
i am working on a windows application. In that i have to open a saved text file using a open dialog box and load it into the word document..i am not able to load a text file to word document. what can i do for this?

Thanks in advance

That sounds like something I had to do for an assignment at University. I had to make an application that allowed the user to create a new document, save, open and close etc.

You may want to look into using the FileStream class

FileStream fs = new FileStream();
fs.DoSomethingHere

I cant remember exactly what the coding is for it ... but hopefully you get the idea ... if its even what you are looking for!

Elmo_loves_you 20 Junior Poster in Training


Right click the stored procedure and check properties -> permissions, add the user if they are not in the list.

Can you post what you are using for your connection string and the scripted stored procedure that sql generated?

My stored procedures dont have that option ! Im no longer at work, but I will post the sql code on monday :)

Thanks for your help in the mean time :)

Elmo_loves_you 20 Junior Poster in Training

SqlConnection myConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|DatabaseName.mdf;Integrated Security=True;User Instance=True");

public void setVehicleDetails2()
        {
            getCompanyID();
            //Holds the ID value for the Customer selected!
            str_CompanyID = (string)i_companyID.ToString();
            //Declare myCommand properties
            myCommand = new SqlCommand("AddNewVehicle", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            //Open connection to the database
            myConnection.Open();

            //Initialise new instances of SqlParameter that declare the data type, size and column name
            //for the data that is being passed in.
            myCommand.Parameters.Add(new SqlParameter("@reg", SqlDbType.NVarChar, 50, "Registration"));
            myCommand.Parameters.Add(new SqlParameter("@manufacturer", SqlDbType.NVarChar, 50, "Manufacturer"));
            myCommand.Parameters.Add(new SqlParameter("@model", SqlDbType.NVarChar, 50, "Model"));
            myCommand.Parameters.Add(new SqlParameter("@genericName", SqlDbType.NVarChar, 50, "GenericName"));
            myCommand.Parameters.Add(new SqlParameter("@fleetNo", SqlDbType.NVarChar, 50, "FleetNo"));
            myCommand.Parameters.Add(new SqlParameter("@serialNo", SqlDbType.NVarChar, 50, "SerialNo"));
            myCommand.Parameters.Add(new SqlParameter("@engineNo", SqlDbType.NVarChar, 50, "EngineNo"));
            myCommand.Parameters.Add(new SqlParameter("@chassisNo", SqlDbType.NVarChar, 50, "ChassisNo"));
            myCommand.Parameters.Add(new SqlParameter("@vinNo", SqlDbType.NVarChar, 50, "VIN_No"));
            myCommand.Parameters.Add(new SqlParameter("@year", SqlDbType.NVarChar, 4, "YearOfManufacture"));
            myCommand.Parameters.Add(new SqlParameter("@colour", SqlDbType.NVarChar, 50, "Colour"));
            myCommand.Parameters.Add(new SqlParameter("@idcompany", SqlDbType.Int, 4, "ID_Company"));           

            //Adds data to the Vehicle and Customer_Vehicle table based on the parameters passed in.
            myCommand.Parameters["@reg"].Value = txt_Ex_Registration.Text;
            myCommand.Parameters["@manufacturer"].Value = txt_Ex_Manufacturer.Text;
            myCommand.Parameters["@model"].Value = txt_Ex_Model.Text;
            myCommand.Parameters["@genericName"].Value = txt_Ex_GenericName.Text;
            myCommand.Parameters["@fleetNo"].Value = txt_Ex_FleetNo.Text;
            myCommand.Parameters["@serialNo"].Value = txt_Ex_SerialNo.Text;
            myCommand.Parameters["@engineNo"].Value = txt_Ex_EngineNo.Text;
            myCommand.Parameters["@chassisNo"].Value = txt_Ex_ChassisNo.Text;
            myCommand.Parameters["@vinNo"].Value = txt_Ex_VinNo.Text;
            myCommand.Parameters["@year"].Value = txt_Ex_Year.Text;
            myCommand.Parameters["@colour"].Value = txt_Ex_Colour.Text;
            myCommand.Parameters["@idcompany"].Value = str_CompanyID;

            //Close and dispose of open properties            
            myCommand.ExecuteNonQuery();

            //myCommand.Dispose();
            myConnection.Close();
        }
Elmo_loves_you 20 Junior Poster in Training

No - its just meant to be a simple app, (an interface to a database) im making it for in-house purposes, so it just has the one user (hardcoded login for now anyway)

Elmo_loves_you 20 Junior Poster in Training

Ensure you have rights, and possible try prefixing with dbo.

And ensure you are specifying the correct database in the sqlconnection

Ive already tried prefixingwith dbo with no joy :( lol

I have other sproc's that work ... like I have an AddCustomers sproc that just inserts the values into the table .... (Eazy peezy)

but ... ive hit a wall now lol....damn big one too

to me now .. my code should add the RIGHT values to the sproc ... except it cant FIND the sproc GRRRR

Elmo_loves_you 20 Junior Poster in Training

I would suggest doing this, calling p_InsertVehicleWithCustomer from the code.

PROCEDURE dbo.AddNewVehicle
	-- Declare variables for inserts into 2 tables
	(
	@reg nvarchar(50),                -- 1
	@manufacturer nvarchar(50), -- 2
	@model nvarchar (50),          -- 3
	@genericName nvarchar(50), -- 4
	@fleetNo nvarchar(50),          -- 5
	@serialNo nvarchar(50),        -- 6
	@engineNo nvarchar(50),       -- 7
	@chassisNo nvarchar(50),      -- 8
	@vinNo nvarchar(50),            -- 9
	@year nvarchar(4),               -- 10
	@colour nvarchar(50),            -- 11
	@idvehicle	int OUTPUT
	)
	
AS
	
	-- Insert all data into the Vehicle table 
	INSERT INTO Vehicle(Registration, Manufacturer, Model, GenericName, FleetNo, SerialNo, EngineNo, ChassisNo, VIN_No, YearOfManufacture, Colour)
	VALUES (@reg, @manufacturer, @model, @genericName, @fleetNo, @serialNo, @engineNo, @chassisNo, @vinNo, @year, @colour)
	
	-- Retrieve the automatically generated ID value from the Vehicle table
	SET @idvehicle = @@IDENTITY
	
	
	RETURN



PROCEDURE dbo.p_InsertVehicleWithCustomer
	(
	@reg nvarchar(50),                -- 1
	@manufacturer nvarchar(50), -- 2
	@model nvarchar (50),          -- 3
	@genericName nvarchar(50), -- 4
	@fleetNo nvarchar(50),          -- 5
	@serialNo nvarchar(50),        -- 6
	@engineNo nvarchar(50),       -- 7
	@chassisNo nvarchar(50),      -- 8
	@vinNo nvarchar(50),            -- 9
	@year nvarchar(4),               -- 10
	@colour nvarchar(50),
	@idcompany int                  -- 12
	)

	DECLARE @idvehicle int
	EXEC AddNewVehicle(@reg, @manufacturer, @model, @genericName, @fleetNo, @serialNo, @engineNo, @chassisNo, @vinNo, @year, @colour, @idvehicle OUTPUT)

	INSERT INTO Customer_Vehicle(ID_Company, ID_Vehicle)
	VALUES(@idcompany, @idvehicle)

I think I see what you are trying to do .. but I have 3 tables

Customer (aka Company)
Vehicle
Customer_Vehicle

so the @idcompany is the primary key from the Customer table

Elmo_loves_you 20 Junior Poster in Training

The code needs to call the stored procedure we have...I believe lol.

What happens when you do this?

myCommand = new SqlCommand("AddNewVehicle", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

stepping through the code in debug mode at that point, it picks up the CommandText as "AddNewVehicle" and stepping on through the rest of the code it see's the values for each of the parameters ...

..but when it reaches myCommand.ExecuteNonQuery(); it bugs out saying:

SqlException was unhandled
Could not find stored procedure 'AddNewVehicle'

NOTE :: I have managed to get the ID value to pass in as a parameter to the sproc ... I had to cast it to a string. (thats me over the ID hurdle) Just need to understand now why it cant FIND the stored procedure !!! :@

Elmo_loves_you 20 Junior Poster in Training

lol what?

I thought you already have the stored procedure in the database, and you are accepting the values through the code.

myCommand = new SqlCommand("CreateVehicle", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

You mean the above code is not hitting the database?

lol

yes - but ... :)

when I test the stored procedure itself...it DOES add to the database...

but when I run the code its throwing a fit!!

Elmo_loves_you 20 Junior Poster in Training

I'm not understanding that if you already have the company_id, why you don't want to pass it in.

You are inserting the new vehicle, and have a company id already.

I would suggest creating two stored procedures. Maintain this one that inserts a vehicle only and another stored procedure that calls to insert the vehicle, gets the id, and makes the call to insert customer vehicle.

Thats a valid point :)

but either way I will still be faced with the problem of inserting the ID value for the Customer name selected from the DropDown list.

How can I write a stored procedure that accepts a variable from the code?

Im confusing myself now with this lol

Elmo_loves_you 20 Junior Poster in Training

I have two different versions of the AddNewVehicle sproc (purely because the program threw a hissy fit by saying it couldnt see the CreateVehicle sproc)

the content of both are the same as defined above.

I have 3 tables (Customer, Vehicle and Customer_Vehicle)

The idea is that somebody could phone in and request information about some product a company sells...the company could record their details on the system...then if that customer decides they would like to buy a product, then the company would be able to search the Existing customers (dropDown list) and then proceed to type in relevant information ... then click on an "ADD" button

this button would then trigger a method that adds the text enetered into textboxex on the interface along with the value stored in the integer variable (referring to the name the user chose from the dropdown list)

So, the integer variable and all the textbox.text values are all passed into their respective parameters of the sproc .... then there should be a successful entry (but theres not)

Elmo_loves_you 20 Junior Poster in Training

The Green highlighted pieces show the code that I had that successfully added the data to the tables but I had to manually enter the ID number ... the code then selected the ID_Company based on that parameter and added to the table new table (all this worked with the Executing the stored procedure and viewing the output in the output window BUT would not recognise that the sproc existed in my code)

I hope this makes sense!

The red pieces of code show the changes that I made to the sproc. I declared the @idcompany inside the sproc with the hope that I could pass in an integer variable declared in my code which stores the ID for ID_Company after the user selects the Company Name from a drop down list.

ALTER PROCEDURE dbo.AddNewVehicle
	-- Declare variables for inserts into 2 tables
	(
	@reg nvarchar(50),                -- 1
	@manufacturer nvarchar(50), -- 2
	@model nvarchar (50),          -- 3
	@genericName nvarchar(50), -- 4
	@fleetNo nvarchar(50),          -- 5
	@serialNo nvarchar(50),        -- 6
	@engineNo nvarchar(50),       -- 7
	@chassisNo nvarchar(50),      -- 8
	@vinNo nvarchar(50),            -- 9
	@year nvarchar(4),               -- 10
	@colour nvarchar(50)            -- 11
	--@idcompany int                  -- 12 (although declared again below)
	)
	
AS
	DECLARE @idvehicle int
	DECLARE @idcompany int  -- newly added
	
	-- Insert all data into the Vehicle table 
	INSERT INTO Vehicle(Registration, Manufacturer, Model, GenericName, FleetNo, SerialNo, EngineNo, ChassisNo, VIN_No, YearOfManufacture, Colour)
	VALUES (@reg, @manufacturer, @model, @genericName, @fleetNo, @serialNo, @engineNo, @chassisNo, @vinNo, @year, @colour)
	
	-- Retrieve the automatically generated …
Elmo_loves_you 20 Junior Poster in Training

Hey People :)

A little quesion for you all ...

I have a stored procedure which retrieves an ID from a Customer table and the ID from the newly Inserted row of the Vehicle table and adds them to a new table.

On my form I have a dropDown where the user can select a Name. I then force my code to get the ID for that name using a stored procedure and have the result stored in an integer variable. So what I was aiming for in the following code was to be able to pass in the integer value in the C# code to the procedure along with the rest of the data and have it save to both tables respectively.

Initially I had the Commented Out code as part of the procedure and on execution of the procedure (and knowing and manually typing the unique ID value for the Customer) it added the data to both tables. However when I ran it from my code it told me it could not find the Procedure or Function named "AddNewVehicle" when it was blatently staring it in the face!!!

As it stands now with the code belowDoes anyone know or hazard a guess as to why I am getting the error "Procedure or Function CreateVehicle has too many arguments specified"

ALTER PROCEDURE dbo.AddNewVehicle
	-- Declare variables for inserts into 2 tables
	(
	@reg nvarchar(50),                -- 1
	@manufacturer nvarchar(50), -- 2
	@model nvarchar (50), …
Elmo_loves_you 20 Junior Poster in Training

I got the combo box issue sorted

was able to get the SelectedIndex value and from there I get the SelectedItem (string)

Elmo_loves_you 20 Junior Poster in Training

yeah fair point !

In ASP.NET there is an onPageLoad() (or something similar) so that you can force a DropDownList to be automatically filled with data ... the user then clicks their desired info and then the SelectedIndexChanged event is fired ... I guess thats why it worked for me before then.

So with Windows Forms - how then do I make sure the Combox box is already filled before the user clicks it (ie .. "Select..." is displayed then the user clicks the dropdown arrow to see the available data).

Ive been playing about with it but havent been having much luck with it