|
i have experienced this before.
despite the fact that parameters are named, you still need to create the right number and the right type of paramers in the ADODB.Command object. basically, what is happening is that the parameters you are passing from vb are not lining up with the proc paramaters the way you think they are.
declare your vb parameter list identically to the sp param list, including the ones you don't realy need (don't set a value for them in vb if you want to use the SPs default values).
it will work then.
#include <beer.h>
|
|
|
|
|
thanks. yes, the orders of parameters in asp script is NOT the same as that as defined in stored procedure - I took time to make sure the parameter NAME ana TYPE matches however. Didnt expect the order would matter too.
Just hope that this is the root of the problem. Will work on it later today and will let you know what happen.
norm
|
|
|
|
|
I need to output from DB2 to MS Excel in C# using INSERT TO statement, how can I do that please?
Many Thanks,
Jassim Rahma
Jassim Rahma
|
|
|
|
|
Hello, the CPians around the world.;)
One time, I try to export some sql statement generated by SQL Server to MySQL on RedHat Linux 7.2
However, I got a bunch of error messages from MySQL Server.
I found that some syntax of SQL statement generated by SQL Server would
be not supported by MySQL.
First time, I try to delete [dbo] from SQL file, but I notice that some
value type will not be supported by MySQL.
Does anyone know any tools to overcome this kind of HELL?
Thank you in advance.
-Masaaki Onishi (eCoolSoft)-
ASP.NET Web and Windows
Application Development by C# and MFC.
eCoolWebPanelBar(BETA) is availabe now.
http://www.ecoolsoft.com
|
|
|
|
|
Everyone has their own SQL syntax...
You might want to try PostgreSQL[.org] instead. You can use it as a back-end to MS Access, so it should be more compaitble than MySQL.
If you're using SQL server, PostgreSQL is a better match for you anyway.
(And no, I know of no tools)
|
|
|
|
|
No thanks, postgresql spammer. Get a real database.
|
|
|
|
|
Indeed I am a PostgreSQL 'spammer'. I do this because when people think open source database they think MySQL is the flag ship. Indeed it is not. PostgreSQL can compete with Oracle on Features while having respectible speed. It's just the most popular because it's always been an easy install under most platforms.
Am I to assume going to assume you prefer the worm-ridden MS SQL server? I think it might be good to mention now that I also think Oracle is good as well, but since this guy was using a MySQL database, it'd be a good assumption he want to stay cheap and free.
What do you suggest is a 'real' database?
|
|
|
|
|
Scorp1us wrote:
What do you suggest is a 'real' database?
Indexed cards and a filing cabinet?
Sorry...
David Wulff http://www.davidwulff.co.uk
|
|
|
|
|
Hi,
I wanna get the number of records of a table from an Access database by CDatabase & CRecordset classes.
What is the appropriate function?
Thank you in advance.
|
|
|
|
|
Hi,
You can pass this query :
Select Count(*) from tableName
|
|
|
|
|
i am a freshman in asp.net , but i have background in asp using visual interdev 6.
i want to display a set of records in a database using datagrid in a web.
can anybody help me how?
mr. boljok
|
|
|
|
|
Dim connection As OLEDBConnection = New OleDBConnection(strConnection)
Dim command As OledbCommand = New OleDbCommand("select * from table",connection)
connection.Open()
dtGrid.DataSource = command.ExecuteReader()
dtGrid.Bind()
Learning and Working
|
|
|
|
|
Hi everybody!
I'm new to ADO and I want to create an MFC Application using ADO for my database manipulation. So I started with an easy example.
In the example, I need to write:
#import "c:\Program Files\Common Files\System\ado\mmado15.dll" no_namespace
rename("EOF", "EndOfFile")
But that doesn't work! I have a error tolding me that WS.NET cannot find msado15.dll.
So I looked at my path and make a research for it and I realize that msado15.dll do not exist.
So where can I find it?
thanks for helping.
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Your example has msado15.dll mispelled. Try this:
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
Darrell Long
|
|
|
|
|
msado15.dll is part of the MDAC[^] run-time.
|
|
|
|
|
Hi, all:
I am totally stuck, please help. I have a datagrid on the WinForm ( using C# ). I am trying to create a combobox for one of the columns. I use the technique described in MS KB Article 323167 ( coded in VB.NET) and I port the code to C#. It works fine for the existing rows. Whe I click on the * row ( i.e., try to create a new row) on the datagrid. The combobox seems there, but when I click on the down arrow, the combobox does not dropdown. Occasionally, I can get the dropdown, but when I leave the cell, the changed value goes to the previous row ( strange!). The primary key is AutoNumber, when I click on the new row ( with "*" in front of it), I sometime get little pencil in front of the row, but sometimes I do not get it except the autonumber ( almost like it does not treat as a new row ).
Has anyone use this combobox technique and work on the new row successfully? I include the code snippet ( handling the events) here, if you can spot anything I did wrong, please let me know.
Any help is highly appreciated. Thanks in advance.
Dion
************ Code Starts here ***********
private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if ( dataGrid1.CurrentCell.ColumnNumber == 1 )<br />
{<br />
cbType.Width = dataGrid1.GetCurrentCellBounds().Width;<br />
}<br />
}<br />
<br />
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)<br />
{<br />
if ( dataGrid1.CurrentCell.ColumnNumber == 1 )<br />
{<br />
cbType.Visible = false;<br />
cbType.Width = 0;<br />
cbType.Left = dataGrid1.GetCurrentCellBounds().Left;<br />
cbType.Top = dataGrid1.GetCurrentCellBounds().Top;<br />
cbType.Text = dataGrid1[dataGrid1.CurrentCell].ToString() + "";<br />
cbType.Visible = true;<br />
}<br />
else<br />
{<br />
cbType.Visible = false;<br />
cbType.Width = 0;<br />
} <br />
}<br />
<br />
private void dataGrid1_Scroll(object sender, System.EventArgs e)<br />
{<br />
cbType.Visible = false;<br />
cbType.Width = 0;<br />
}<br />
<br />
<br />
private void dataGrid1_Click(object sender, System.EventArgs e)<br />
{<br />
cbType.Visible = false;<br />
cbType.Width = 0;<br />
}<br />
<br />
<br />
private void cbType_TextChanged(object sender, System.EventArgs e)<br />
{<br />
if ( dataGrid1.CurrentCell.ColumnNumber == 1 )<br />
{<br />
cbType.Visible = false;<br />
<br />
if ( ( dataGrid1[dataGrid1.CurrentCell] + "") == "" )<br />
{<br />
SendKeys.Send("*");<br />
}<br />
<br />
dataGrid1[dataGrid1.CurrentCell] = cbType.Text;<br />
} <br />
}
|
|
|
|
|
i tried to add records to my database table but cant due to foreign key problem.. how do i solve tat?
i tried deleting all the relationships and i was able to add successfully but not when i add in the relationships.
2 tables involved:
tblcompany
- accountnumber (primary key)
- companyname
- address
tblcustomer
- customerid (primary key, auto generated)
- companyname [foreign key]
- username
- password
- name
- contactnumber
are these tables linked correctly? can someone help? thanks in advance
Laine
|
|
|
|
|
Using string fields as keys is most of the time A Bad Idea.
Its not really clear from your table synopsis which is the "parent" and which is the "child" in your data logic. So i'll ignore what you've done and use a fictional example.
tblCompanies
------------
CompanyId (primary key, autonumber)
CompanyName
CompanyAddress
Company PhoneNumber
tblEmployees
------------
EmployeeId (primary key, autonumber)
CompanyId (foreign key)
EmployeeName
EmployeeInsideLegMeasurement
I hope that example makes it more clear.
#include <beer.h>
|
|
|
|
|
thanks for ur reply jon.. the company table is the parent and the customer/employee table is the child.
the company data muz exist before the employee can sign up to be a member..
the data field for the companyID is alphanumeric.. and employees have problem remembering their company account number.. that's why i choose that they enter their company name instead.. this is to identify which employee from which company logs on.
any idea on how to go about designing a better database than the one i did earlier? any comments, suggestions will be deeply appreciated..
Laine
|
|
|
|
|
If you wanna make so that the employees enter alphanumeric strings, why don't you make a column with that and an ID column for key?
|
|
|
|
|
First of all:
1. What DB do you use? Oracle, SQL-Server, Access, DB2?
2. Post your error message (or error code)
3. Post your table-definitons
4. Post the INSERTs you tried.
Some things you should check:
1. Most DBs are case sensitive. So 'comp1' != 'Comp1' => master-key won't be found
2. Even if it sounds silly -> Check for typing errors!
3. Be sure to create a company before creating a customer for it.
4. You can only delete a record from tblcompany if no record of tblcustomer is referencing to it.
The included example should work (assuming accountnumber, customerid and contactnumber to be NUMBERS, the others VARCHAR)
INSERT INTO tblcompany VALUES(1, 'comp1', 'someaddress');<br />
INSERT INTO tblcompany VALUES(2, 'comp2', 'someaddress');<br />
<br />
INSERT INTO tblcustomer (companyname, username, password, name, contactnumber) VALUES ('comp1', 'uname', '***', 'name', 1);
--
karl
|
|
|
|
|
i am using sql server2000. when i try to add a record to the database, the following error occurred:
"INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_tblCustomer_tblCompany'. The conflict occurred in database 'myDatabase', table 'tblCompany', column 'accountnumber'. The statement has been terminated."
i am sure that all the spellings are correct and there are no typing mistakes anywhere.
the tables involved are:
tblcompany
- accountnumber (primary key) : varchar
- companyname : varchar
- address : varchar
tblcustomer
- customerid (primary key, auto generated) : int
- companyname [foreign key] : varchar
- username : varchar
- password : varchar
- name : varchar
- contactnumber : int
the parent would be tblcompany whereas the customer table as the child.
i am using a stored procedure:
ALTER Procedure AddCustomer
(
@CompanyName varchar(50),
@Username varchar(50),
@Password varchar(50),
@Name varchar(50),
@PhoneNo varchar(50)
)
AS
INSERT INTO tblCustomer
(CompanyName, Username, Password, Name, PhoneNo)
VALUES
(@CompanyName, @Username, @Password, @Name, @PhoneNo)
RETURN
this is how i call the stored procedure:
Public Sub processRegistration(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim CompanyName As String = txtCompany.Text
Dim Username As String = txtUsername.Text
Dim Password As String = txtPassword.Text
Dim Name As String = txtName.Text
Dim PhoneNo As String = txtContact.Text
Dim ocm As SqlClient.SqlCommand
ocm = New SqlClient.SqlCommand("AddCustomer", SqlConnection1)
ocm.CommandType = CommandType.StoredProcedure
Dim pcompanyname As SqlClient.SqlParameter
pcompanyname = New SqlClient.SqlParameter("@CompanyName", SqlDbType.VarChar, 50)
pcompanyname.Value = CompanyName
ocm.Parameters.Add(pcompanyname)
Dim pusername As SqlClient.SqlParameter
pusername = New SqlClient.SqlParameter("@Username", SqlDbType.VarChar, 50)
pusername.Value = Username
ocm.Parameters.Add(pusername)
.
.
SqlConnection1.Open()
ocm.ExecuteNonQuery()
SqlConnection1.Close()
End Sub
i have the company data in the tblcompany, but i juz couldnt add a customer to the customer table.
can anyone tell me wat is wrong?
Laine
|
|
|
|
|
ylaine wrote:
tblcompany
- accountnumber (primary key) : varchar
- companyname : varchar
- address : varchar
tblcustomer
- customerid (primary key, auto generated) : int
- companyname [foreign key] : varchar
- username : varchar
- password : varchar
- name : varchar
- contactnumber : int
The foreign key in tblcustomer references to the PRIMARY KEY of tblcompany. So it references to accountnumber and not to companyname. If you want to set a foreign key to companyname you must define it as UNIQUE in tblcompany and change the fk-constraint to point to companyname.
--
karl
|
|
|
|
|
ok.. got it.. thank you very much karl!;)
Laine
|
|
|
|
|
Hiya I am just wondering if anyone has come across this problem.
I have an SQL database which I read and write to. I write a number of items( Number, Planet Name )the first time to the database fine. The items go in fine and in order into their columns:
e.g 1. Jupitar 2. Venus 3. Mars 4. Earth
Then when I modify the table in some way, e.g like deleting all the items, and refill the table with the exact same code, they come out in a different order e.g
3. Mars 1. Jupitar 4. Earth 2. Venus
And I definitely have not changed the code and they are all definitely deleted. WEIRD!! I have also done this with ACCESS database and works fine every time, only wrong in SQL.
Does anyone have any ideas on this??
grahamoj.
|
|
|
|