SHARE
TWEET

Untitled

a guest Sep 3rd, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. error in mysql syntax?
  2. ERROR [HY000] [MySQL][ODBC 3.51 Driver][mysqld-5.5.9]Not unique table/alias: 'WallPosting'
  3.    
  4. {
  5.  
  6.     string theUserId = Session["UserID"].ToString();
  7.     using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=x; Password=x;"))
  8.     {
  9.         cn.Open();
  10.         using (OdbcCommand cmd = new OdbcCommand("SELECT WallPosting.Wallpostings FROM WallPosting LEFT JOIN WallPosting ON User.UserID = WallPosting.UserID WHERE User.UserID=" + theUserId + "", cn))
  11. // problem in select statement
  12.  
  13.         using (OdbcDataReader reader = cmd.ExecuteReader())
  14.         {
  15.             var divHtml = new System.Text.StringBuilder("<div id=mysqlcontent>");
  16.             while (reader.Read())
  17.             {
  18.                 divHtml.Append(String.Format("{0}", reader.GetString(0)));
  19.             }
  20.  
  21.             divHtml.Append("</div>");
  22.             test1.InnerHtml = divHtml.ToString();
  23.  
  24.         }
  25.     }
  26. }
  27.    
  28. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  29. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  30. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
  31. CREATE SCHEMA IF NOT EXISTS `gymwebsite2` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
  32. USE `gymwebsite2` ;
  33.  
  34. -- -----------------------------------------------------
  35. -- Table `gymwebsite2`.`User`
  36. -- -----------------------------------------------------
  37. CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`User` (
  38.   `UserID` INT NOT NULL AUTO_INCREMENT ,
  39.   `Email` VARCHAR(245) NULL ,
  40.   `FirstName` VARCHAR(45) NULL ,
  41.   `SecondName` VARCHAR(45) NULL ,
  42.   `DOB` VARCHAR(45) NULL ,
  43.   `Location` VARCHAR(45) NULL ,
  44.   `Aboutme` VARCHAR(1045) NULL ,
  45.   `username` VARCHAR(45) NULL ,
  46.   `password` VARCHAR(45) NULL ,
  47.   PRIMARY KEY (`UserID`) )
  48. ENGINE = InnoDB;
  49.  
  50. -- -----------------------------------------------------
  51. -- Table `gymwebsite2`.`WallPosting`
  52. -- -----------------------------------------------------
  53. CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`WallPosting` (
  54.   `idWallPosting` INT NOT NULL AUTO_INCREMENT ,
  55.   `UserID` INT NOT NULL ,
  56.   `Wallpostings` VARCHAR(2045) NULL ,
  57.   PRIMARY KEY (`idWallPosting`) ,
  58.   INDEX `fk_WallPosting_User` (`UserID` ASC) ,
  59.   CONSTRAINT `fk_WallPosting_User`
  60.     FOREIGN KEY (`UserID` )
  61.     REFERENCES `gymwebsite2`.`User` (`UserID` )
  62.     ON DELETE NO ACTION
  63.     ON UPDATE NO ACTION)
  64. ENGINE = InnoDB;
  65.  
  66. -- -----------------------------------------------------
  67. -- Table `gymwebsite2`.`Pictures`
  68. -- -----------------------------------------------------
  69. CREATE  TABLE IF NOT EXISTS `gymwebsite2`.`Pictures` (
  70.   `idPictures` INT NOT NULL AUTO_INCREMENT ,
  71.   `UserID` INT NOT NULL ,
  72.   `picturepath` VARCHAR(1045) NULL ,
  73.   PRIMARY KEY (`idPictures`) ,
  74.   INDEX `fk_Pictures_User1` (`UserID` ASC) ,
  75.   CONSTRAINT `fk_Pictures_User1`
  76.     FOREIGN KEY (`UserID` )
  77.     REFERENCES `gymwebsite2`.`User` (`UserID` )
  78.     ON DELETE NO ACTION
  79.     ON UPDATE NO ACTION)
  80. ENGINE = InnoDB;
  81.  
  82. SET SQL_MODE=@OLD_SQL_MODE;
  83. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  84. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  85.    
  86. SELECT WallPosting.Wallpostings FROM WallPosting LEFT JOIN USER ON User.UserID = WallPosting.UserID WHERE User.UserID=" + theUserId + "", cn
  87.    
  88. WallPosting LEFT JOIN WALLPOSTING ON User.UserID = WallPosting.UserID
  89.    
  90. "SELECT WallPosting.Wallpostings FROM WallPosting LEFT JOIN User ON User.UserID = WallPosting.UserID WHERE User.UserID=" + theUserId + ""
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top