|
|
Thank you Colin. One more thing, how to cast float with scale of two (two digits to the right of the decimal point).
<italic>Work hard, Work effectively.
|
|
|
|
|
I am using DataSet to insert a data row which contains a 6MByte binary file in "Data" column.
According to the MySQL manual for 4.0, I define the "Data" column as "longblob", which suppose to store up to 4GByte file. But it just doesn't work.
With the exact same code, if my data is less than 100KByte, it works fine.
Can anybody tell if I have to config anywhere else to make this work?
From MySQL 4.0, the maximum allowed length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory.
I just wonder what "client/server protocol" refers to? How can I figure out the maximum packet size?
|
|
|
|
|
Hi,
Mikey just sorted out my first problem, the next one is this.
In my stored procedure in sqlserver i used OUTPUT Parameters, im not sure i can do this in MYSQL as im not using stored procedure;
this is my code;
' the connection string
myconnection = New MySqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
' the query
strSQL = "SELECT ?SubDesc=SubDesc, ?SubName=SubCatName FROM SubCategory WHERE SubcatID = ?SubID;"
mycommand = New MySqlCommand(strSQL, myconnection)
' Input Parameter
Dim parameterSubID As MySqlParameter = New MySqlParameter("?SubID", SubCatID)
mycommand.Parameters.Add(parameterSubID)
' Output Parameter
Dim parameterSubCatDesc As MySqlParameter = New MySqlParameter("?SubDesc", MySqlDbType.String, 500)
parameterSubCatDesc.Direction = ParameterDirection.Output
mycommand.Parameters.Add(parameterSubCatDesc)
Dim parameterSubName As MySqlParameter = New MySqlParameter("?SubName", MySqlDbType.String, 50)
parameterSubName.Direction = ParameterDirection.Output
mycommand.Parameters.Add(parameterSubName)
' execute read
myconnection.Open()
mycommand.ExecuteNonQuery()
myconnection.Close()
Label1.Text = CStr(parameterSubCatDesc.Value)
Label2.Text = CStr(parameterSubName.Value)
I dont know if anyone can help me on this? Mike what about this one!
Cheers
Jetset
|
|
|
|
|
i forgot to say the problem,
the code runs but nothing is returned in the labels
|
|
|
|
|
Is there any way to create function that can return a recordset? i tried to do it but...
i forgot... the other thing is how to "catch" returned recordset? does CRecordset have any copy constructor or sth?
|
|
|
|
|
Can somebody tell me how to get this done on SQL reporting.
I need to print the column headings vertically like this H
E
A
D
I
N
G
instead of this - HEADING
thanx
|
|
|
|
|
I wrote a stored procedure to do a simple update to a table in one of my dbs:
ALTER PROCEDURE usp_cmrapprupd<br />
(@id nvarchar(50),@name int,@appr nvarchar(1))<br />
AS<br />
UPDATE approvers SET approver_identifier = @name, approved_by_approver = @appr<br />
<br />
WHERE identifier = @id
now, with the exception of @id being an nvarchar, this stored procedure is identicle to another one for another table. the only difference between the two tables is that one uses integers as the id, and the other uses nvarchars.
the update on the int table works just dandy, but the one listed about keeps giving me the following error:
Violation of PRIMARY KEY constraint 'PK_approvers'. Cannot insert duplicate key in object 'approvers'.
What is giving me a headache is how am I violating primary key constraints if i am doing an update rather than insert?
Update:
OKay, I discovered a consistancy. The table uses both identifier and approver_identifier as primary keys. If i try to update something with a single instance of identifier, it works (example, identifier 1-1 has 3, 1-1 with approver_identifier of 1, 1-1 with approver_identifier of 2, etc, i get the error. however, if i have an identifier of 4-1 and only an approver_identifier of 1, the update works)
Any ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Okie dokie... Iguess this works the same as venting to a stranger.. Putting things out for others to see makes you look it over in a new light. I figured it out:
ALTER PROCEDURE usp_cmrapprupd<br />
(@id nvarchar(50),@name int,@appr nvarchar(1))<br />
AS<br />
UPDATE approvers SET approved_by_approver = @appr<br />
<br />
WHERE identifier = @id AND approver_identifier = @name
Apparently, the proc didnt know which field to update (which makes sense when you dont specify both identifiers....)
This procedure works like a charm. Thanks for letting me complain
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
hi all,
I wonder if anyone can help with this one, alls im trying to do is add a parameter to a query, i have tried for days but cannot get this to work!!
heres my code;
myConnection = New MySqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
strSQL = "SELECT SubCatID,CategoryID,SubCatName,Multibuy,SubCatPic FROM SubCategory WHERE CategoryID = ?CategoryID AND Multibuy='Single' ORDER BY SubCatName, SubCatID;"
Command = New MySqlCommand(strSQL, myConnection)
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
Command.Parameters.Add("?CategoryID", 1)
Command.Parameters("?CategoryID").Direction = ParameterDirection.Input
I get the error ;
Parameter '?CategoryID' must be defined
i have tried everyway i think possible, PLEASE i hope someone can help or point me in the right direction!
Thanks.
Jetset
|
|
|
|
|
Hi there. Do you need to issue the .Prepare() method after setting up your Command ?
|
|
|
|
|
.Prepare method?
Out of all the searches Ive done on google ive not seen this mentioned before?
could you expand on this?
Thanks.
|
|
|
|
|
Hi there. I may have offered that too soon - I saw it used in some MySql .NET Connector examples and thought it may be something to look at. As I look at the .chm documentation, it indicates that the method is not yet supported (?) But then there is a different section that describes the following:
4.3.2. Preparing Statements in MySQL Connector/NET
To prepare a statement, create a command object and set the .CommandText property to your query.
After entering your statement, call the .Prepare method of the MySqlCommand object. After the statement is prepared, add parameters for each of the dynamic elements in the query.
After you enter your query and enter parameters, execute the statement using the .ExecuteNonQuery(), .ExecuteScalar(), or .ExecuteReader methods.
For subsequent executions, you need only modify the values of the parameters and call the execute method again, there is no need to set the .CommandText property or redefine the parameters.
So now I'm not sure which is right.
|
|
|
|
|
Mike,
Thanks alot, you have helped me out loads with that, my parameter code was correct but becuase I wasnt using the execute read method it wasnt working!
It is now!
Thanks alot
Jet set
|
|
|
|
|
Hi all,
i want to export the result of a query to an excel/csv file.if nyone has an idea about it, please let me know. need it badly..
thanks & regards,
manasi
|
|
|
|
|
if csv is ok for you just create a normal txt file with values seperated by comas and change file extension to csv.
|
|
|
|
|
This works with ADO,
CString sql = _T("SELECT * INTO [Excel 8.0;DATABASE=" + strExcelFileLoc + <br />
"].[" + strWorksheetName + "] FROM [" + strTable + "]");<br />
<br />
DB->Execute(sql.AllocSysString());
The results are outputted strait to the excel file specified by strExcelFileLoc.
Hope this helps....
-------------------------------
|
|
|
|
|
Hello,
I have a child table that contains rows related to a parent table. I would like, in a single SELECT query for the parent table, to have two counts, one for rows in the child table that match a certain criteria, and another that match some other criteria.
A simple example, a table of Classrooms , with a child table Students , where each student is either male of female; and the query should return ClassroomID , NumMales , and NumFemales .
I can easily get only one count (males for example) using GROUP BY with something like:
SELECT COUNT(StudentID) AS NumMales FROM Students
GROUP BY Sex WHERE Sex = 0 but I can't find a way to get two different aggregate functions to work on the same table.
In my case it's actually a bit more complicated, because I have three tables related. But a little pointer on how to do it with two tables should help me get started.
Any ideas? Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Like this:
SELECT COUNT(StudentID) AS Females,<br />
(SELECT COUNT(StudentID) AS Males<br />
FROM dbo.Students<br />
WHERE (Sex = 'M')) AS Males<br />
FROM dbo.Students AS Students_1<br />
WHERE (Sex = 'F')
|
|
|
|
|
|
Is there anything like C# style ternary operator in SQL?
|
|
|
|
|
|
Very many thanks for your great answer, Colin
|
|
|
|
|
I created a dts package that imports data into sqlserver. I run the dts package from a vb.net application on a machine that does not have sqlserver installed. I get the error quoted above. I used an installer project to install my vb.net application on the machine running the application.
Included in the folder with my exe is dtspkg.dll, Interop.DTS.dll, as well as some other config and dll files. Why am I getting this error?
|
|
|
|
|
It sounds like you need to redistribute the DTS files.
The interop library is just a component which uses these files.
Have a look at this[^].
|
|
|
|
|