|
Had another crack with those two, but still getting errors.
Type Mismatch on JOIN expression:
str_SQL = "UPDATE SubCategory SET SubCategory.SubCategoryDesc = '" & str_New & "' " _
& "WHERE SubCategory.CategoryKey IN " _
& "(SELECT SubCategory.SubCategoryDesc FROM SubCategory " _
& "INNER JOIN Category ON Category.CategoryKey = SubCategory.CategoryKey " _
& "WHERE ((Category.CategoryDescription)= '" & GetCurrCategory & "') " _
& "AND ((SubCategory.SubCategoryDesc)= '" & str_Old & "'))"
Missing Operator in Query "FROM Category ..... = Subcategory.CategoryKey":
str_SQL = "UPDATE SubCategory " _
& "SET SubCategory.SubCategoryDesc = '" & str_New & "' " _
& "FROM Category " _
& "INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey " _
& "WHERE ((Category.CategoryDescription) = '" & GetCurrCategory & "') " _
& "AND ((SubCategory.SubCategoryDesc)= '" & str_Old & "')"
I've played around with it, but still can't get it to work. Any more ideas?
Cheers
Cata
|
|
|
|
|
Never mind
Thanks for the help, it was pretty much spot on.
Needed to be using SubCategoryKey rather than the CategoryKey. One was specific, the other one was general.
Cheers again
Cata
|
|
|
|
|
No worries, glad to help
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
There is no correlation between the queries in the update statement. No matter which row the SQL Server tests, the EXISTS statement will always resolve to true and therefore, update the row.
I don't think the EXISTS statement is a good solution for this problem (although you could make it work). Try the IN statement:
UPDATE
SubCategory
SET
SubCategory.SubCategoryDesc = str_New
WHERE
SubCategory.SubCategoryDesc IN
(SELECT
SubCategory.SubCategoryDesc
FROM
Category
INNER JOIN
SubCategory
ON Category.CategoryKey = SubCategory.CategoryKey
WHERE
((Category.CategoryDescription)= GetCurrCategor()) AND
((SubCategory.SubCategoryDesc)= str_Old))
|
|
|
|
|
Hi,
In an excel sheet, I have a column (text format), but if I try open this using ODBC driver, this column is open as double data type. Exist any way to change the data type for each column?
I don't want to use a TEXT function from excel, this resolve my problem, but I want another way to chnage it.
Thank you.
ALX
|
|
|
|
|
What am I doing wrong? I do not get any output
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
OleDbConnection1.Open()
OleDbDataAdapter1.SelectCommand.CommandText = "SELECT Location, HotelID FROM Hotel"
OleDbDataAdapter1.SelectCommand.ExecuteNonQuery()
Do
ComboBox1.Items.Add(OleDbDataAdapter1.SelectCommand.CommandText)
Loop
OleDbConnection1.Close()
End Sub
|
|
|
|
|
skicrud wrote:
What am I doing wrong? I do not get any output
Can you tell use, what do you want to do?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Dont exactly know what you are trying to do here but shouldn't you instead of putting executeNonQuery() put in executeReader()??
I dont know what the do loop is for either??
Try filling a datatable or dataset with you adapter i.e oledbDataAdapter1.fill(myDatatable)
then use your datatable to fill your comboBox ie.
comboBox1.datasource = myDataTable
comboBox1.valueMember = "hotelID"
comboBox1.displayMember = "Location"
ComboBox1.DataBind()
Something like that anyways.
|
|
|
|
|
Hi, guys.
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC. Every time such information is prompted:"SQL Server doesn't exist or access denied."
By the way, the SQL Server service manager running on my PC can start or stop MSDE on both local and remote PC.
Help please. Thanks.
vigorous
|
|
|
|
|
wk_vigorous wrote:
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC
What is the version of your windows operating system? Does your windows install any service pack?
wk_vigorous wrote:
SQL Server doesn't exist or access denied
Try to check the information from here[^] and google.
wk_vigorous wrote:
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC
Try to check the connection library.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
The operating system is xp sp2. I thought maybe the firewall block relevant port but even i close the firewall i still can't connet to MSDE.
vigorous
|
|
|
|
|
This is probably an SP2 issue. Have a look at MS KB 841249[^] - How to configure Windows XP Service Pack 2 (SP2) for use with SQL Server.
Another problem I have seen is if all protocols are disabled. Run the server network utility (svrnetcn.exe ), and make sure you have at least one protocol in the "Enabled protocols" list.
http://www.trinet.co.uk/kb.asp?kbid=25[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Thank you very much.
It's because the protocol is disabled. Now MSDE could be connected after enable the protocol.
vigorous
|
|
|
|
|
Hi there guys,
Have a couple of issues to do with SQLXML on SQL2K...
Firstly, have created a new stored procedure that I wish to expose as a SOAP method. Have added the sproc and can execute within QA, but when I come to add it to the virtual names in SQLXML, when browsing the list of available sprocs, it's not there....have tried all sorts of ways to "force" it to appear in the lsit, but to no avail....On the one occasion I did manage to get it sorted, when calling the method, my app just hung. Completely. Totally....any ideas?
Second probelm seems to be that with an OCX on an ASP page, when calling ANY SOAP method exposed by SQLXML, the session is destroyed, and hence all the session variables....again - any ideas?
Cheers guys.....
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Sorry, could not think of a better subject line for this. I need an int stored in my table that is sequential, but will fill in any missing numbers. By this I mean if I have 4 records, these will be numbered 1,2,3,4. If I delete row 3, the next row to be inserted should use row 3. I just need some advice on how to do this.
|
|
|
|
|
I never code this style but this is what I just think and express my concept to you.
toticow wrote:
if I have 4 records, these will be numbered 1,2,3,4. If I delete row 3, the next row to be inserted should use row 3.
First make sure that you have have the table structure and the first field of your table is set to number (data type) and order it by ascending. When you delete any record from your database, you have to requery your table and order the first field. Then you have to count the total amount of your record in the database, after that make a loop from the first row to the second, third... until the end of row (the amount of loop process is base on the total number of record in the database). And in the each loop process you have to change the value of the first field to match the amount of loop proces. This might help you to solve the problem, if you still have the problem I will try to do it and post the code for your.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi, firstly I agree with you about coding in this style. I always use auto numbers. This table in fact has one, but this other id is actualy for a memory location. We have a device with a limited amount of memory, that can only be written to by memory location. This table will always be small, less than 100 records, but deletions and additions will occur, which prevent me using the primary key. I am probably wrong, but I thought that this would be the best way to do it. I am in the process now of trying your suggestion. Thank you
|
|
|
|
|
You could create a second table which contains a list of deleted numbers. If the table is empty the the next number you use is MAX(numberColumn)+1 .
In order to populate the deleted numbers table you can create a delete trigger on the original table and insert the relevant row. When you are inserting a new record just take a number from the deleted numbers table and use that - remember to remove it from the deleted numbers table. You could create an insert trigger to do this for you.
However, this will still leave gaps in your sequence if you delete a row and don't insert one afterwards.
Do you want to know more?
|
|
|
|
|
Hi, I use the following statment in VB.Net to add new record in my database:
INSERT INTO tblSellTo (ProdID, CusName) VALUES(1,'abc')
and delete the record from the database using the following statement:
DELETE FROM tblSellTo WHERE tblSellTo.ProdID =1 AND tblSellTo.CusName LIKE 'abc'
Both of these statement are working fine!!!
But my problem is occure when I want to update the record. Suppose that I have Product ID =1 and customer name is 'abc' and I want to update the information to Product ID =1 and customer name is change to 'wkl' and I use the following code:
INSERT INTO tblSellTo (ProdID, CusName) VALUES(1,'wkl') WHERE tblSellTo.ProdID =1 AND tblSellTo.CusName LIKE 'abc'
But it is not success, it display an error message that missing character ; at the end of sql statement . But when I try to change the code to:
INSERT INTO tblSellTo (ProdID, CusName) VALUES(1,'wkl') WHERE tblSellTo.ProdID =1 AND tblSellTo.CusName LIKE 'abc';
It still the same, it is not working. Does anyone have any idea about solveing this problem?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Bingo, now it is working. I use the following statement:
UPDATE tblSellTo SET tblSellTo.ProdID =1, tblSellTo.CusName ='wkl' WHERE tblSellTo.ProdID =1 AND tblSellTo.CusName LIKE 'abc'
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I have an access db with a boolean field called manager.
When my vb form loads it populates a combo box with user names from the same table.
As I select a user I need to have the appropriate radio button checked, either manager if true or employee is false, based on the value of manager in the DB
Any help would be appreciated
|
|
|
|
|
skicrud wrote:
When my vb form loads it populates a combo box with user names from the same table.
If it is possible, please post the structure of your table on this forum. I used to do the similar project like you too and my solution is add the other field beside the user name. The field could be boolean (Yes/No) or list of text to describe the function of each people. Remember to select the user name and function of the people in to recordset. Then display only the name in the combobox and the other field is hidden and just analayse only for your radio button.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Mon problème est de créer une transaction sous ACCESS 2003 en VB comprenant deux requêtes:
- une requête de suppression d'un enregistrement dans une table distante liée par un pont ODBC
- la suppression du même enregistrement dans la table locale liée au formulaire sur lequel est placé le bouton qui lance la routine suivante:
Un warning s'affiche à l'éxécution de la suppression de l'enregistrement courant:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
En répondant NON à ce warning : "voulez vous supprimer...", une erreur se produit(jusque là tout est normal),
Alors le wks.Rollback devrait restaurer la suppression effectuée (rst.Delete) or il n'en est rien
Ce qui désynchronise mes deux bases.
pourquoi le rollback ne s'effectue pas?
voici mon code:
'macro du formulaire lié à la table locale membres
Private Sub ButDel_Click()
'** Bouton Supprimer
Dim TransStarted As Boolean
Dim db As DAO.Database
Dim wks As DAO.Workspace
Dim rst As DAO.Recordset
'Creation du workspace
Set wks = DBEngine(0)
'début de la transaction
wks.BeginTrans
TransStarted = True
'base courante
Set db = wks(0)
'selection de l'enregistrement à supprimer dans la table fiches_annuaire(table liée ODBC)
sqltext = "select * from fiches_annuaire where code = " & Me.ID
Set rst = db.OpenRecordset(sqltext, dbOpenDynaset)
On Error GoTo ErrDel
rst.MoveFirst ' goto the first record that needs to be inserted
'suppression de l'enregistrement(table liée ODBC)
rst.Delete
'supression de l'enregistrement dans la table liée au formulaire
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "base locale mise à jour", vbOKCancel
'on termine la transaction
If TransStarted Then
wks.CommitTrans
rst.Close
wks.Close
Set wks = Nothing
End If
TransStarted = False
GoTo endsub
ErrDel:
'PopupError
message = "Une erreur est survenue. Pour assurer la synchronisation des deux bases, aucune suppression n'a été effectuée " & vbCrLf & _
"Veuillez recommencer ultérieurement"
glyph = vbExclamation
Title = "Transaction annulée"
'on annule la transaction
If TransStarted Then
wks.Rollback
rst.Close
wks.Close
Set wks = Nothing
MsgBox message & "rollback?", glyph, Title
Else
MsgBox "pas de rollback!", glyph, Title
End If
TransStarted = False
GoTo sql_error_exit:
'Resume Next
sql_error_exit:
Exit Sub
endsub:
On Error GoTo 0
End Sub
|
|
|
|
|
i have a table on my database wich may have a duplicated ID numbers on the column ID so i'm using distinct to eleminate this duplication, but some of the data type of the columns are text or ntext so i'v failed on using distinct but i want to make this job by any way, can anyone help ?
|
|
|
|
|
If it is just duplicates in the ID number that you want to eliminate (for this I am assuming you mean eliminate from a select result rather than actually delete the records) then you might want to try something like:
SELECT MyTable.*
FROM MyTable
INNER JOIN (SELECT ID, MAX(TiebreakerColumn) as TiebreakerColumn
FROM MyTable
GROUP BY ID) AS SubQuery
ON SubQuery.ID = MyTable.ID
AND SubQuery.TiebreakerColumn = MyTable.TiebreakerColumn
It really depends on the data you have, especially being able to specify a "tiebreaker column" for the case when you want to remove the duplicates. The tiebreaker column must be unique within the ID and it must be aggregatable (By that that you can use an aggregation function that returns an actual value from the table, like MIN() or MAX(), but not AVG() or SUM())
Does this help?
Do you want to know more?
|
|
|
|
|